|
I have a detailsview showing data from 2 tables. One of the data fields in the detailsview is a link for another page.
The link is created using <a id=.. runat=server target="_blank>..etc
In the Page_Load, I am using code like -
DetailsViewRow row = dvParams.Rows[0];<br />
tbox = (TextBox)(row.FindControl("txtEqpID"));<br />
anchorSpEquipment = (HtmlAnchor)(row.FindControl("lnkSpEquipment"));<br />
anchorSpEquipment.HRef = "....."<br />
It works fine but if edit-update/cancel is clicked, the link goes away, leaving only the text. So, I put the same code above in the detailsview PreRender event handler and it started to work fine.
But to edit this field(in edit mode), I have a dropdown list with values populated from another table in the database. To do that - I needed to put code in the PreRenderagain.
As soon as I did that, the previous code is giving me null reference on the HtmlAnchor object. I tried to move the code in other EventHandlers like ModeChanging,ItemCommand - but everywhere it does the same...even in the Page_load if I move it outside of the !Page.IsPostBack, it gives the error.
Any ideas? Thanks.
|
|
|
|
|
This looks nasty, why not ust define the link in your aspx ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I tried that as well - and it's giving me the same error.
Is there any other way?
Thanks.
|
|
|
|
|
I got it figured out, thanks Christian.
I did this: in the DataBound event handler, to filter the exception - I used if:
<br />
if (dvParams.CurrentMode != DetailsViewMode.Edit)<br />
{<br />
DetailsViewRow row = dvParams.Rows[0];<br />
tbox = (TextBox)(row.FindControl("txtEqpID"));<br />
HtmlAnchor anchorSpEquipment = (HtmlAnchor)(row.FindControl("lnkSpEquipment"));<br />
anchorSpEquipment.HRef = "~/EquipmentDetails.aspx?Station=" + stationID + "&ColType=" + collType + "&Param=" + paramID + "&ID=" + tbox.Text;<br />
}<br />
|
|
|
|
|
I've been trying to create a simple method to update iframe content via a mix of asp.net and javascript. I can set a meta refresh, but that makes for a lot of traffic. I had created an aspx page that loaded into a hidden iframe (which did a meta refresh every 60 sec). This aspx would connect to a database and check for updated content, a "yes" or "no" in a table field. If "yes" then it would spit out some javascript code to reload the appropriate iFrame. But, there seems to be a couple of problem with this in that, one, the hidden aspx doesn't seem to load or execute but once. The other is that the javascript code isn't reloading the appropriate iframe.
I would think this approach should work. I probably don't have it coded correctly. But, what I want to ask was if this method is a reasonable approach? Is there a better way of doing content updates without a lot of overhead code loading into the browser?
Thanks
|
|
|
|
|
If you want the page to refresh itself, a js timer is the only way to do that. If only part of the page refreshes, you can use AJAX to make requests for that data.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
HI
Can any one let me know, how to create different subdomains using ASP.NET C#, e.g if My URL is www.Mydomain.com if any user gets registered then the users own subdomain get created e.g. www.UserName.MyDomain.com, can any one let me know how to do it , can any one provide me any code snippet, thanks in advance,
regards,
Tippu
|
|
|
|
|
The only code that could do this, is URL rewriting. Look at HTTP handlers.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Can you send me any code?
|
|
|
|
|
No, I can't. I know that ASP.NET as it's typically used, plainly can't change a URL. URL rewriting can, and I know where to look for that info in ASP.NET. That's why my reply was tentative. I've not done it, I just know enough about ASP.NET to know where I'd look, so I gave you some keywords to type into google. Good luck.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
How about you read about this and write an artice with source code?
Yusuf
|
|
|
|
|
Hello sir,
On registering our details to a new website, we recieve a confirmation mail along with user name, and password. How is it possibile? How can i do so using c#?
|
|
|
|
|
Nothing special... just during registration enter all the info into table, and leave the active field of the database as false. Send a confirmation mail with one transaction id, which you hold to the database upto a certain time... When the user clicks on the link you have provided with the email, it opens up a new page for activation, you can get the transaction id through query string or else ask the user to enter....
If the user enters correct transaction id, you can update the active bit field in the database and make the user active....
Simple..
|
|
|
|
|
Check This[^] Post. That is similar post like you. You will get a better idea from that.
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
in class mail
public static void SendMail(string MailTo, string MailFrom, string Subject,String MailBody)
{
System.Net.Mail.MailMessage objMailMessage = new System.Net.Mail.MailMessage(MailFrom, MailTo);
objMailMessage.Subject = Subject;
objMailMessage.IsBodyHtml = true;
objMailMessage.Body = MailBody;
SmtpClient objsmtp = new SmtpClient();
objsmtp.Send(objMailMessage);
}
in aspx.cs call Sendmail function
string Subject="Hoe to send mail";
strimg MailBody=" Dear user your Username=" +username +"";
"password ="+ password;
SendMail(to@mail.com, from@mail.com, Subject,MailBody)
and also set smtp setting in webconfig
|
|
|
|
|
Hello sir,
I have to encrypt my password.I used the following statement.
string pswd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPswd.Text, SHA1 );
Error message is "SHA1 is a type not a variable".
How can i do?
|
|
|
|
|
The second parameter is expecting a string not an enum.
Try this:
string pswd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPswd.Text, <code>"SHA1"</code> );
Kelly Herald
Software Developer
|
|
|
|
|
Sir,
How can i decode it again to login?
|
|
|
|
|
A hash is one way. It cannot be decrypted. However, you can just compare the newly generated hash with the one stored like below.
string storedpswd = ...
string newpswd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPswd.Text, "SHA1" );
if (newpswd == storedpswd)
{
}else
{
}
Kelly Herald
Software Developer
|
|
|
|
|
Sir,
To encrypt and also decrypt what algorithm can be used
|
|
|
|
|
You can use TripleDES, Rijndael, or any of the non-hashing algorithms located in the System.Security.Cryptography namespace. Below is a link to MSDN's library for the TripleDES class and it has a complete example of how to encrypt and decrypt data. The other algorithms can also be found in the MSDN library.
TripleDESCryptoServiceProvider Class[^]
Kelly Herald
Software Developer
|
|
|
|
|
How can the exception generated due to Page validation be caught ?
I am having RequestValidation=True (which is default) on my page.
Now, if the user enters some HTML tags, an exception is generated ...
How can that error be caught in the page where it occurred, so that the user can be asked not to enter html tags .... there itself ....
Please help me here ....
Apurv
A man is but the product of his thoughts. What he thinks, he becomes.
.......Mahatma Gandhi
Be the change you want to see in the world.
.......Mahatma Gandhi
|
|
|
|
|
are you talking about Page.IsValid property... you will only find that in postbacks.
|
|
|
|
|
Is there any equivalent to this when a combo is data bound? I've been through this hundreds of times before, but I'm having a brain freeze moment.
|
|
|
|
|
Is this[^] what you looking for?
Yusuf
|
|
|
|