如果我添加runat =“"服务器",href单击问题; asp.net中的属性

编程入门 行业动态 更新时间:2024-10-24 21:25:38
本文介绍了如果我添加runat =“"服务器",href单击问题; asp中的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是aspx页面上的一个href

here is one href on aspx page

ASPX:

<a id="hrfReport" href="<%=sApplicationURL%>Reports.aspx">Report</a>

代码隐藏:

sApplicationURL = "localhost/";

现在,如果我单击重定向到报告页面的href页面,但是如果我添加runat ="server"属性,则href单击不起作用.实际上,我想在特定条件下将其禁用.

now if i click on href page redirected to the reports page but if i add runat="server" attribute then href click not worked.actually i want to make it disable on particular condition.

有人知道怎么做吗?

推荐答案

您不能在服务器标签中使用<%=someVal%>构造.编译器基本上将其翻译为Response.Write(someVal).

You cannot use the <%=someVal%> construct in server tags. The compiler basically translates that to Response.Write(someVal).

您可以使用<%#someVal%>构造,但是需要DataBind()值.例如:

You can use the <%#someVal%> construct, but you are required to DataBind() the value. For example:

ASPX:

<a id="hrfReport" href='<%#sApplicationURL + "Reports.aspx"%>' runat="server">Report</a>

代码隐藏:

sApplicationURL = "localhost/"; hrfReport.DataBind();

或者...

如果有服务器控件,则可以从后面的代码中设置其属性,如下所示:

If you have a server control, you can set its properties from the code behind as follows:

ASPX:

<a id="hrfReport" runat="server">Report</a>

代码隐藏:

hrfReport.HRef = sApplicationURL + "Reports.aspx";

更多推荐

如果我添加runat =“&quot;服务器&quot;,href单击问题; asp.net中的属性

本文发布于:2023-06-08 03:54:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/576154.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单击   属性   服务器   quot   amp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!