I received a userid and comment in URI from a user on a website. On button click I want to submit it but I want to make conditional so if the URI doesn't contains userid and password then I don't want to apply the URI analysis and allowing the user to type the userid and comment and press the button manually. I hope I explain correctly with my limited knowledge. The question first part is here
Asked
Active
Viewed 113 times
1 Answers
2
From the previous question you are getting the query parameters as:
var result = System.Web.HttpUtility.ParseQueryString(uri.Query);
You can check for userid
and comments
like:
if (result.HasKeys("userid"))
{
// found
}
or you can compare against null like:
if (result["userid"] == null)
{
//not found
}

Habib
- 219,104
- 29
- 407
- 436
-
It makes sense, so on button click i will first check if it is null then do nothing. right? BTW how can I assign userid to textbox in c# textbox.?? – Dr. Mian Jun 05 '15 at 15:20
-
`textbox.Text = result["userid"];` – Habib Jun 05 '15 at 15:20
-
One more problem is that I want to skip/bypass the page if uri is available. any suggestions? – Dr. Mian Jun 05 '15 at 15:33
-
I am assuming I will copy paste my code from button click event to page load event. Inside the if condition. right? – Dr. Mian Jun 05 '15 at 15:34
-
It worked but for me the textbox.Text = result["userid"]; didnt work so i assigned it to the string variable and assigned that variable to the textbox.text and voila. all working. – Dr. Mian Jun 05 '15 at 15:46