获得一个URL参数到asp.net标签
问题描述:
我想自动设置一个ASP的文本:标签的URL参数,但它似乎并没有工作。
I am trying to automatically set the text of a asp:label to a url parameter but it does not seem to work.
这是code我有:
<asp:Label ID="lblHouse" runat="server"
Text='<%# Request.QueryString["Selection"] %>'
Font-Bold="True"
Font-Size="Large"></asp:Label> <br /> <br />
我是什么做错了吗?
What am I doing wrong?
感谢您的帮助。
答
您可以使用&lt;%=%>(而不是&LT;%#),并把它的ASP内部:标签标记,而不是Text属性
You can use <%= %> (instead of <%#) and put it inside of the asp:label tag, instead of the Text property:
<asp:Label ID="lblHouse" runat="server"
Font-Bold="True"
Font-Size="Large"><%= Server.HTMLEncode(Request.QueryString["Selection"]) %></asp:Label>