从Ahref标签访问服务器端变量 [英] Acessing server side variable from Ahref tag
问题描述
嗨
i需要为我的href访问服务器端变量,在运行时我需要将变量内的内容作为Href标记的url传递。
下面是我的aspx代码:
< a id =btnSaverunat =serverhref =<%= strAddUrl%>class =按钮>添加
我声明的cs文件中的
,
公共字符串strAddUrl;
并且在运行时你将被传递给这个字符串。
但是我得到一个错误的BAD URL,请帮助我。
Hi
i need to acess the server side variable for my href, at run time i need to passs the content inside variable as the url for the Href tag.
below is my aspx code:
<a id="btnSave" runat="server" href="<%=strAddUrl%> " class="button">Add
in my cs file i declared,
public string strAddUrl;
and at run time ur will be passed to this string.
but iam getting an error BAD URL,pls help me out.
推荐答案
在页面加载中写下波纹管线
in page load write bellow line
string strAddUrl = "http://www.google.com";
Session["strAddUrl"] = strAddUrl;
&在aspx页面中
a href ='<%= Session [strAddUrl]。ToString()%>'>测试
& in aspx page
a href='<%= Session["strAddUrl"].ToString() %>'>Testing
这篇关于从Ahref标签访问服务器端变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!