Tips Centre Thursday, November 21, 2024

Home Home | About Us About Us | Contact Us Contact Us

vrPakistanis Technologies - Web Development, Logo Designing, Web Designing

Home > ASP.Net

Count The Number Of Parameters In A Query String

In this programming tutorial you will learn how to count the number of parameters of a query string in asp.net using c#. Some times you may wanted to know how many parameters your query string contains so that you can implement appropriate checks in your code according to your requirement. In asp.net finding parameters are quite easy. Let's have a look over the code snippet given below:

protected void Page_Load(object sender, EventArgs e)
{
Int16 totalParameters;
if (!Page.IsPostBack)
{
totalParameters = Request.QueryString.AllKeys.Length;
Response.Write("The number of parameters the query string contains are "+totalParameters);
}
}

So that's it. The Request.QueryString.AllKeys.Length will give you what you want.

This article has been taken from Nice Tutorials

Tips Centre 2008-2021. All rights reserved. Developed by vrPakistanis Technologies.