dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersGaurav Arora
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Forums » .NET » ASP.NET »

How to handel querystring in asp.net


Posted Date: 13 Jun 2012      Posted By:: Manohar     Member Level: Silver    Member Rank: 893     Points: 2   Responses: 5



in my application i used linkbutton and button to redirect to same page . i used query string in linkbutton and button control. if i clicked on button control it goes to page and display error that nullrefrence exception was unhandeled by user of linkbutton querystring value.



Responses

#675263    Author: Anil Kumar Pandey      Member Level: Platinum      Member Rank: 1     Date: 13/Jun/2012   Rating: 2 out of 52 out of 5     Points: 2

The value of the Query string might be coming as Null. Please bind the value correctly as


<asp:LinkButton ID="lnkName" runat="server" PostBackUrl='<%# Eval("ID", "Test.aspx?ID={0}") %>'></asp:LinkButton>



Thanks & Regards
Anil Kumar Pandey
Microsoft MVP, DNS MVM



 
#675310    Author: sudhajosyula      Member Level: Gold      Member Rank: 46     Date: 13/Jun/2012   Rating: 2 out of 52 out of 5     Points: 2

try the code below as:


protected void button1_click(object sender,eventargs e)
{
string sno=1;
Response.Redirect("Test.aspx?ID="+sno);
}
protected void lnkbtn_click(object sender,eventargs e)
{
string h=9;
Response.Redirect("Test.aspx?ID="+h);
}



 
#675322    Author: Asheej T K        Member Level: Diamond      Member Rank: 2     Date: 13/Jun/2012   Rating: 2 out of 52 out of 5     Points: 2

Hi,
can you post the code you are using to assign the query string and read the query string. It seems you are not assigning the query string value properly.


Regards,
Asheej T K
Microsoft MVP[ASP.NET/IIS]
DotNetSpider MVM

Dotnet Galaxy






 
#675337    Author: Siva Prasad      Member Level: Gold      Member Rank: 60     Date: 13/Jun/2012   Rating: 2 out of 52 out of 5     Points: 2


protected void Button1_Click1(object sender, EventArgs e)
{
string strNo = "786";
Response.Redirect("Siva.aspx?strId=" + strNo);
}

protected void lnkbtn_Click1(object sender, EventArgs e)
{
string strNum = "555";
Response.Redirect("Siva.aspx?strId=" + strNum);
}



public partial class Siva : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.txtBox1.Text = Request.QueryString["strId"];
}
}



 
#675371    Author: Ravindran        Member Level: Diamond      Member Rank: 3     Date: 13/Jun/2012   Rating: 2 out of 52 out of 5     Points: 3

Hi,

this error is due to come when the query string value is null try like this to avoid error


string qrystringval;
try
{
qrystringval = Request.QueryString["qrystringname"];
}
catch(Exception ex)
{
}


In the above if query string come in the url then assign it in variable otherwise not and also error not come

Regards
N.Ravindran
Your Hard work never fails



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : RegisterForEventValidation Error
Previous : Data show in textbox same as google search textbox without using ajax
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.