ASP.NET - get querystring value in mvc

Asked By ankita
09-Sep-10 03:17 AM
I have made one mvc application in which i have used urlrewriting but when i want to access querystring so i cannot get the value of querystring.
it is like below

CompanyDetails?CompanyID=C000000015
in which companyDetails is the page name which is of aspx page and i want to get the value of CompanyID

i wrote below syntax
Request.QueryString["CompanyID"].ToString()
but i dont get the value.
  Goniey N replied to ankita
09-Sep-10 03:40 AM
-- Some Changes Are Required :

-- Write "aspx" page & Value In Double Quotes....

CompanyDetails.aspx?CompanyID="C000000015"

-- Store In Some String Variable...
string CompId= Request.QueryString["CompanyID"].ToString()


Finally Your Code :

01.//Code Bhind Of Source Page....
02. 
03.private void BtnGo_Click (object sender, System.EventArgs e)
04.{
05.  string URL;
06.  //Store Whole Querystring Into The URL String Variable...
07.  URL="CompanyDetails.aspx?CompanyID="C000000015";
08.  Response.Redirect(URL);
09.}
10. 
11. 
12. 
13.//Code Behind Of CompanyDetails.aspx Page....
14.private void Page_Load (object sender, System.EventArgs e)
15.{
16.  //Store Value Of CompanyID Into LblCompId Lable
17.  LblCompId.Text=Request.QueryString["CompanyID"];
18.}



-- For More Details See My FAQ - How To Use Query String?

-- hope This Will Work At Your Side.....
  Thiyagu S replied to ankita
09-Sep-10 03:40 AM
companydetail is name of the webform????????

      if it is then give like this companydetail.aspx
  ankita replied to Thiyagu S
09-Sep-10 06:00 AM
YEs but its url routing so it wont show the aspx.It will show only webform name
Create New Account
help
Net hi friends Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an IL? (B A) What is scavenging? (B) What are different types of caching using cache object of ASP.NET? (B) How can you cache different version of same page using ASP.NET cache object? (A) How will implement Page Fragment Caching? (B) Can you compare ASP.NET sessions with classic ASP? (B) Which are
in Sql server as var_name int How do you separate business logic while creating an ASP.NET application? There are two level of asp.net debugging 1. Page level debugging For this we have to edit the page level debugging enable the trace to true in the line in the html format of the page. %@ Page Language = ”vb” trace = ”true”AutoEventWireup = ”false” Codebehind = ”WebForm1.aspx.vb” Inherits = ”WebApplication2.WebForm1?> 2
ASP.NET Caching Basics ASP.NET Caching Basics by Peter A. Bromberg, Ph.D. Peter Bromberg "If people had understood how Caching? Caching is one of the least used and misunderstood, yet most powerful features of ASP.NET - - both in the 1.1 flavor, and even more so in ASP.NET 2.0. Most developers do not get into the details of harnessing the power of
Request.Querystring in asp.net designer page Hi, Can anyone say how to use request.Querystring in master page (designer page), Since i don't have codebehind page for master page? Don't understand "Since i don't have codebehind page for master
i want that after selecting that particular company every detail should be show on next page in gridview from database. plz help me From Dropdown List the Value which u r getting pass it as a Query String on 2nd page. . . like below response.redirect("page2.aspx"?Name = ddlname.selecteditem.text); and on second page where u r binding the grid for that u must passing some query to get for Name and in that where condition pass the value which u r getting frm Querystring and then bind the grid. . . . For ex. . . on 2nd page "select * from table where Name = Request.Querystring["Name"]"; for example this query collection u get in datatable called dt then after pass so here u got the value of Name which u passed by name on 1st page. . . Hope u understand my point 01. In page1 write, Response.Redirect( "CT.aspx?id = " + TextBox1 03. In page2(CT.aspx) write the following 04. 05. protected void Page_Load( object sender, EventArgs e) 06. { 07. string ID = Request.QueryString[ "id" ]; 08. string query = "SELECT * FROM company WHERE