ASP.net超链接使用嵌入式代码浏览URL [英] ASP.net Hyperlink Navigate URL with embedded code
本文介绍了ASP.net超链接使用嵌入式代码浏览URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在用c#开发一个ASp.net Web应用程序,其中有一个超链接,该超链接打开另一个传递查询字符串参数的网页.它传递用户输入的文本框数据作为查询字符串.
这是我的代码:
< asp:HyperLink ID =" ="span> runat =" 服务器" 目标 _ blank" NavigateUrl =" <% = txtStartDate.Text%>" >
单击超链接后,它将打开NewPage.aspx,但StartDate的查询字符串值是<%= txtStartDate.Text%>.本身.
我如何在NewPage.aspx中获取文本框值.请帮忙
预先感谢,
Sruthi R
解决方案
在NewPage.aspx中尝试string StartDate = Page.Request.QueryString["StartDate"];
.
阅读这篇文章 [ ^ ]可能会为您提供进一步的了解.
您需要为GetTextBoxValue编写一个单独的脚本,如下所示:
函数 GetTextBoxValue(id) { 返回 文档 .getElementById(id).value; }
您的代码将被重写为:
< asp:hyperlink id =" runat =" 服务器" 目标 _ blank" navigateurl =" xmlns:asp =" > /asp:超链接 <asp:HyperLink ID="linkActiveCount" runat="server" Target="_blank" NavigateUrl="~/Reporting/NewPage.aspx?Index=4&StartDate=<% =txtStartDate.Text %>">
On click of hyperlink it opens NewPage.aspx, but the querystring value of StartDate is <%=txtStartDate.Text%> itself.
How do i get the textbox value in NewPage.aspx. Please help
Thanks in advance,
Sruthi R解决方案Trystring StartDate = Page.Request.QueryString["StartDate"];
in NewPage.aspx.
Reading this article[^] may give you further insight.
You need to write a separate script for GetTextBoxValue as:
function GetTextBoxValue(id) { return document.getElementById(id).value; }
your code will be rewritten as:
<asp:hyperlink id="linkActiveCount" runat="server" target="_blank" navigateurl="~/Reporting/NewPage.aspx?Index=4&StartDate=" xmlns:asp="#unknown"></asp:hyperlink>
这篇关于ASP.net超链接使用嵌入式代码浏览URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文