开发者

querystring in asp.net

开发者 https://www.devze.com 2023-01-16 07:43 出处:网络
how to use querystring开发者_JS百科 in asp.net.It depends on what exactly query.string did in the language you refer to, but...

how to use querystring开发者_JS百科 in asp.net.


It depends on what exactly query.string did in the language you refer to, but...

Request.QueryString["MyValue"];

http://msdn.microsoft.com/en-us/library/system.web.httprequest.querystring.aspx


Good article realted to query string

ASP.NET Client Side State Management - Query Strings

Passing variables between pages using QueryString


Request.QueryString["StringValue"];


  <html xmlns="http://www.w3.org/1999/xhtml">  
  <head runat="server">  
  <title>asp.net QueryString example: how to use QueryString</title>  
  </head>  
  <body>  
    <form id="form1" runat="server">  
    <div>  
    <h2 style="color:Navy">QueryString Example</h2>  
    <asp:HyperLink   
        ID="HyperLink1"  
        runat="server"  
        NavigateUrl="~/Image.aspx?ImageID=1&ImageName=Elephant"  
        Text="Test QueryString"  
        >  
    </asp:HyperLink>  
</div>  
</form>  


you can also use button click event instead of page load.

protected void Page_Load(object sender, System.EventArgs e) {  
    string ID = Request.QueryString["ImageID"];  
    string Name = Request.QueryString["ImageName"];  
    Label1.Text = "ImageID: "+ ID;  
    Label2.Text = "Image name: "+ Name;  
    Image1.ImageUrl = "~/Images/"+Name+".jpg";  
}  
0

精彩评论

暂无评论...
验证码 换一张
取 消