how to get query string value in c# code example
Example 1: querstring fromat asp.net c#
public partial class QueryStringValuesTransfer : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string id1 = Server.UrlDecode(Request.QueryString["id"]);
string name1 = Server.UrlDecode(Request.QueryString["name"]);
Response.Write(id1 + name1);
}
Example 2: get query string parameter from string value c#
Uri myUri = new Uri("http://www.example.com?param1=good¶m2=bad");
string param1 = HttpUtility.ParseQueryString(myUri.Query).Get("param1");
Example 3: querstring fromat asp.net c#
[TestMethod]
public void QueryStringTest()
{
string str = "http://mysite.com/page1?id=3123&format=json&action=edit&text=It's%20a%20brave%20new%20world!";
var query = new UrlEncodingParser(str);
Assert.IsTrue(query["id"] == "3123");
Assert.IsTrue(query["format"] == "json","wrong format " + query["format"]);
Assert.IsTrue(query["action"] == "edit");
Console.WriteLine(query["text"]);
query["id"] = "4123";
query["format"] = "xml";
query["name"] = "<< It's a brave new world!";
var url = query.ToString();
Console.WriteLine(url);
}
Example 4: how to read reportview query string asp.net c#
ReportParameter rpt7 = new ReportParameter(**PARAMETER NAME**, **VALUE**);
this.ReportViewer1.ServerReport.SetParameters(new ReportParameter[] { rpt7 });
Example 5: how to read reportview query string asp.net c#
protected void Page_Load(object sender, EventArgs e)
{
....
ReportViewer1.ServerReport.ReportPath = _myReportPart;
ReportViewer1.ServerReport.ReportServerUrl = new Uri(myReportServerUrl);
}
}