[英]read a id from Request.QueryString
hello im tying to read id from Request.QueryString in html tage in asp.net but it can work and read a velue by Request.QueryString from url. 您好打算从asp.net的html年代的Request.QueryString中读取ID,但是它可以工作,并可以从URL中的Request.QueryString中读取消息。 here is a code which i used below 这是我在下面使用的代码
<video src='<%# "VideoHandler.ashx?id=" + Request.QueryString["id"] ' width="220"
height="200" controls="" preload=""></video>
please let me know how can i bid this in fount hand tag in asp.net 请让我知道如何在asp.net的原始手标中出价
First, you need to close your server tag 首先,您需要关闭服务器标签
<video src='<%# "VideoHandler.ashx?id=" + Request.QueryString["id"] %>' width="220"
height="200" controls="" preload=""></video>
Second... 第二...
I've always found it easier to add this to a protected function in the code behind and call the function in the mark up. 我总是发现将其添加到后面代码中的受保护函数中并在标记中调用该函数更加容易。
So (assuming c#) I would have 因此(假设使用C#)
protected string getHandler(){
return "VideoHandler.ashx?id=" + Server.UrlEncode(Request.QueryString["id"]);
}
Then in the markup just have 然后在标记中
<video src='<%# getHandler() %> ' width="220"
height="200" controls="" preload=""></video>
You forgot to close your server side tag and you shouldn't have your string in your tag. 您忘记了关闭服务器端标签,并且标签中不应包含字符串。 src property should look like so: src属性应如下所示:
VideoHandler.ashx?id=<%# Request.QueryString["id"] %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.