捕获超链接文本属性 [英] Capture hyperlink text property
问题描述
我有一个aspx页面(此处称为page_1),其数据网格的第一个
列包含超链接。当用户点击其中一个超链接时,他将b / b
将导航到另一个aspx页面(此处称为page_2)。我需要
缓存链接'的文本(hyperlink.text属性)的值,这样我就可以在第2页的page_load事件中使用它。
。 />
我想过使用隐藏字段然后在page_2的Page_Load事件中调用
Request.Form(" hdnClickedLinkText")。我点什么不知道如何在点击
超链接时填充第_1页的hdnClickedLinkText字段。我已经考虑过使用AddHandler但是没有
暴露的单击事件用于超链接控件。我可以设计一个自定义类
,它继承自超链接类并实现我自己的Click事件,但
这似乎有点多,当一个更简单的解决方案可能存在时。 />
有没有人有任何其他想法?
TIA,
-
Joe
VB.NET/C#/ASP.NET/ASP/VB/C++/Web和数据库开发/ VBA自动化
I have an aspx page (referred to here as page_1) with a datagrid whose first
column contains hyperlinks. When a user clicks one of these hyperlinks, he
will navigate to another aspx page (referred to here as page_2). I need to
cache the value of the link''s text (hyperlink.text property) so that I can
use it in the page_load event of page_2.
I''ve thought of using a hidden field and then calling
Request.Form("hdnClickedLinkText") in the Page_Load event of page_2. What I
don''t know is how to populate the hdnClickedLinkText field on page_1 when the
hyperlink is clicked. I''ve thought about using AddHandler but there is no
exposed click event for the hyperlink control. I could design a custom class
which inherits from the hyperlink class and implement my own Click event, but
this seems a bit much when a simpler solution may exist.
Does anyone have any other ideas?
TIA,
--
Joe
VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
推荐答案
这是一个标准的HREF还是有回发?如果它是标准的HREF
,你必须将调用传递给一些客户端代码,传入文本,
然后处理它并重定向。如果它是回发你可以更轻松地获得
信息,但更重要的是你可以用它做你想要/需要的东西
then(session value,querystring等)。
-
Curt Christianson
网站: http://www.darkfalz.com
博客: http://blog.darkfalz.com
" Joe"写道:
is this a standard HREF or does it have a postback? If it''s a standard HREF
you will have to pass the call to some clientside code, passing in the text,
and then processing it and redirecting. If it''s a postback you can get the
info more easily but more importantly you can do what you want/need with it
then (session value, querystring, etc).
--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
"Joe" wrote:
我有一个aspx页面(此处称为page_1),其数据网格的第一个
列包含超链接。当用户单击其中一个超链接时,他将导航到另一个aspx页面(此处称为page_2)。我需要缓存链接'的文本(hyperlink.text属性)的值,以便我可以在page_2的page_load事件中使用它。
我'我们想过在第2页的Page_Load事件中使用隐藏字段然后调用Request.Form(" hdnClickedLinkText")。我不知道的是当点击
超链接时如何在第_1页上填充hdnClickedLinkText字段。我已经考虑过使用AddHandler但是没有用于超链接控件的公开点击事件。我可以设计一个自定义类
,它继承自超链接类并实现我自己的Click事件,但是当一个更简单的解决方案可能存在时,这似乎有点多了。
有没有人还有其他想法吗?
TIA,
-
Joe
VB.NET / C#/ ASP.NET / ASP / VB / C + +/ Web和DB开发/ VBA自动化
I have an aspx page (referred to here as page_1) with a datagrid whose first
column contains hyperlinks. When a user clicks one of these hyperlinks, he
will navigate to another aspx page (referred to here as page_2). I need to
cache the value of the link''s text (hyperlink.text property) so that I can
use it in the page_load event of page_2.
I''ve thought of using a hidden field and then calling
Request.Form("hdnClickedLinkText") in the Page_Load event of page_2. What I
don''t know is how to populate the hdnClickedLinkText field on page_1 when the
hyperlink is clicked. I''ve thought about using AddHandler but there is no
exposed click event for the hyperlink control. I could design a custom class
which inherits from the hyperlink class and implement my own Click event, but
this seems a bit much when a simpler solution may exist.
Does anyone have any other ideas?
TIA,
--
Joe
VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
标准HREF;没有回发。 page_1和page_2是两个不同的
页面。
每个href看起来像:href =" page_2.aspx?q1 = value1& q2 = value2"其中
value1和value2从链接更改为链接。
另外,我没有选择在查询字符串中传递text属性。
page_2只需要超链接文本的值。一旦我得到它,我就可以处理
处理。我只是不知道如何得到它。
所以,任何想法?
例如,你将如何通过调用一些客户端代码,在文本中传递
?
谢谢,
-
Joe
VB.NET/C#/ASP.NET/ASP/VB/C++/Web和数据库开发/ VBA自动化
" Curt_C [MVP]"写道:
Standard HREF; there is no postback. page_1 and page_2 are two different
pages.
Each href looks something like: href="page_2.aspx?q1=value1&q2=value2" where
value1 and value2 change from link to link.
Also, I do not have the option to pass the text property in the querystring.
page_2 merely needs the value of the hyperlink''s text. I can handle the
processing once I''ve got it. I just don''t know how to get it.
So, any ideas?
For example, how would you "pass the call to some clientside code, passing
in the text?"
Thanks,
--
Joe
VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Curt_C [MVP]" wrote:
这是一个标准的HREF还是有回发?如果它是一个标准的HREF
你将不得不将调用传递给一些客户端代码,传入文本,
然后处理它并重定向。如果它是回发你可以更轻松地获得
信息,但更重要的是你可以用它做你想要/需要的事情(会话值,查询字符串等)。
-
Curt Christianson
网站: http://www.darkfalz。 com
博客: http://blog.darkfalz.com
乔写道:
is this a standard HREF or does it have a postback? If it''s a standard HREF
you will have to pass the call to some clientside code, passing in the text,
and then processing it and redirecting. If it''s a postback you can get the
info more easily but more importantly you can do what you want/need with it
then (session value, querystring, etc).
--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
"Joe" wrote:
我有一个aspx页面(此处称为page_1),其数据网格的第一个
列包含超链接。当用户单击其中一个超链接时,他将导航到另一个aspx页面(此处称为page_2)。我需要缓存链接'的文本(hyperlink.text属性)的值,以便我可以在page_2的page_load事件中使用它。
我'我们想过在第2页的Page_Load事件中使用隐藏字段然后调用Request.Form(" hdnClickedLinkText")。我不知道的是当点击
超链接时如何在第_1页上填充hdnClickedLinkText字段。我已经考虑过使用AddHandler但是没有用于超链接控件的公开点击事件。我可以设计一个自定义类
,它继承自超链接类并实现我自己的Click事件,但是当一个更简单的解决方案可能存在时,这似乎有点多了。
有没有人还有其他想法吗?
TIA,
-
Joe
VB.NET / C#/ ASP.NET / ASP / VB / C + +/ Web和DB开发/ VBA自动化
I have an aspx page (referred to here as page_1) with a datagrid whose first
column contains hyperlinks. When a user clicks one of these hyperlinks, he
will navigate to another aspx page (referred to here as page_2). I need to
cache the value of the link''s text (hyperlink.text property) so that I can
use it in the page_load event of page_2.
I''ve thought of using a hidden field and then calling
Request.Form("hdnClickedLinkText") in the Page_Load event of page_2. What I
don''t know is how to populate the hdnClickedLinkText field on page_1 when the
hyperlink is clicked. I''ve thought about using AddHandler but there is no
exposed click event for the hyperlink control. I could design a custom class
which inherits from the hyperlink class and implement my own Click event, but
this seems a bit much when a simpler solution may exist.
Does anyone have any other ideas?
TIA,
--
Joe
VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
您好Joe,
两种解决方案:
1.仍在数据网格中使用超链接列,但在
datagrid_itemDatabound事件中添加内容:
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
HyperLink link =(HyperLink)e .Item.Cells [link_column_index] .Controls [0];
link.NavigateUrl + ="& text =" + link.Text;
}
然后在第2页,您可以从查询字符串中检索它。
2 。将超链接列更改为LinkButton。然后你可以处理
datagrid_ItemCommand事件:将数据传递给Session,Cookie或queryString,然后
重定向到第2页。
HTH >
Elton Wang
" Joe"写道:
Hi Joe,
Two solutions:
1. Still use Hyperlink column in the datagrid, but add something in
datagrid_itemDatabound event:
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
HyperLink link = (HyperLink)e.Item.Cells[link_column_index].Controls[0];
link.NavigateUrl += "&text=" + link.Text;
}
Then in page2, you can retrieve it from querystring.
2. Change Hyperlink column to LinkButton. Then you can process in
datagrid_ItemCommand event: pass data to Session, Cookie, or queryString and
redirect to page2.
HTH
Elton Wang
"Joe" wrote:
我有一个aspx页面(此处称为page_1),其数据网格的第一个
列包含超链接。当用户单击其中一个超链接时,他将导航到另一个aspx页面(此处称为page_2)。我需要缓存链接'的文本(hyperlink.text属性)的值,以便我可以在page_2的page_load事件中使用它。
我'我们想过在第2页的Page_Load事件中使用隐藏字段然后调用Request.Form(" hdnClickedLinkText")。我不知道的是当点击
超链接时如何在第_1页上填充hdnClickedLinkText字段。我已经考虑过使用AddHandler但是没有用于超链接控件的公开点击事件。我可以设计一个自定义类
,它继承自超链接类并实现我自己的Click事件,但是当一个更简单的解决方案可能存在时,这似乎有点多了。
有没有人还有其他想法吗?
TIA,
-
Joe
VB.NET / C#/ ASP.NET / ASP / VB / C + +/ Web和DB开发/ VBA自动化
I have an aspx page (referred to here as page_1) with a datagrid whose first
column contains hyperlinks. When a user clicks one of these hyperlinks, he
will navigate to another aspx page (referred to here as page_2). I need to
cache the value of the link''s text (hyperlink.text property) so that I can
use it in the page_load event of page_2.
I''ve thought of using a hidden field and then calling
Request.Form("hdnClickedLinkText") in the Page_Load event of page_2. What I
don''t know is how to populate the hdnClickedLinkText field on page_1 when the
hyperlink is clicked. I''ve thought about using AddHandler but there is no
exposed click event for the hyperlink control. I could design a custom class
which inherits from the hyperlink class and implement my own Click event, but
this seems a bit much when a simpler solution may exist.
Does anyone have any other ideas?
TIA,
--
Joe
VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
这篇关于捕获超链接文本属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!