when i pass a query string from first page to next page.the next page variable cannot get the query string value and the error value cannot be null,parameter name addreses error will occur.how can i solve this
in table.aspx
in mail.aspx.cs
string
System.Net.Mail.
message.From =
message.To.Add(mailid1);//value cannot be null,parameter name addresses error will occur
new MailAddress(from);MailMessage message = new System.Net.Mail.MailMessage();mailid1 = Request.QueryString["mailid"];
karthi vimalaPosted Mar 2, 2011, 5:53 AM
Thanks for the solution.
Suthish NairPosted Mar 2, 2011, 3:00 AM
abhishek dikshitPosted Mar 1, 2011, 1:15 PM
First thing first, always remember to check for NULL value in case of Query String or Session or any State Mgmt tech you are using.
It can be done with the help of code as below
if (Request.QueryString["Name"] != null)
{
}
You can also do one thing
In Code file use a function like this
private string ReturnComMailID(string ComMailId)
{
string _comMailId;
if (ComMailId != null)
{
_comMailId = ComMailId;
}
else
{
_comMailId = "";
}
return _comMailId;
}
And in Design file use this function like the code below
<asp:Label ID="Label1" runat="server" Text='<%#ReturnComMailID(Convert.ToString(Eval("Name")) %>'>asp:Label>
By this means you can easily validate the values.
Happy coding.
From
Abhishek Dikshit
Mark the post as Answer if it helped you.
Suthish NairPosted Mar 1, 2011, 11:45 AM
"'mail.aspx?mailid=<%#Eval("cmpnymailid")%>' id="a1">Apply Here"
krithika muthukrishnanPosted Mar 1, 2011, 6:54 AM
already i passed the values from .aspx page to .aspx.cs page in my project they are all works well,
mailid1 = Request.QueryString["mailid"];
the request.querystring can get the value from mailid but it couldn't assign the value to mailid1,the mailid1 shows null value so only the error will occur,
but i dont know why Request.Querystring cannot assign the value to mailid1.
Krishna GaradPosted Mar 1, 2011, 6:28 AM
Queristring generally we use to pass value from one page to another page.