将查询参数添加到NavigateURL [英] Adding query parameters to the NavigateURL

查看:87
本文介绍了将查询参数添加到NavigateURL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要将当前页面的查询添加到NavigateURL(在同一页面的一个控件中使用)。我必须在前端(即).aspx页面而不是后端执行此操作。我已经解释了一个小例子我的要求是什么..



考虑我有一个名为Hello.aspx的页面。这有id =1作为查询字符串



在Hello.aspx中

我有一个控件说HyperLink说helloHyperLink。我必须将当前页面中的相同查询分配给NavigateUrl标记,例如:NavigateUrl =something(Welcome.aspx)。这里使用与Hello.aspx相同的参数调用welcome.aspx。

Hi,
I need to add the query of the current page to the NavigateURL( which is used in one of the control in the same page). I have to do it on the front end(i.e).aspx page rather than the back end. I have explained a small example of What my requirement is..

Consider I have a Page called "Hello.aspx". This has id="1" as query string

In Hello.aspx
I have a control say HyperLink say helloHyperLink. I have to assign the same query that is in the current page to the NavigateUrl tag eg: NavigateUrl="something("Welcome.aspx")". here the welcome.aspx is called with the same parameters that the Hello.aspx have.

推荐答案

我们可以使用Javascript来支持



调用javascript的超链接可以如下所示



We can use Javascript for that

Hyperlink to call the javascript can be given as below

<asp:HyperLink ID="hyperLnk" runat="server" Text="click here" NavigateUrl="javascript:openWinNavigateUrl()"></asp:HyperLink>





和Javascript可以给出





and the Javascript can be given as

function openWinNavigateUrl() {
            // getting the query string
            var query = document.location.href;

           // Getting the index of required parameter. here I use parameter "id"
            var n = query.indexOf("id");

            //removing the parameter name
            var queryString = query.substring(n + 3, query.length);

            //here I use the querystring to open the new Window
             window.open("Window.aspx?id=" + queryString);
        }


查看ASP.NETs Request对象:



ie :

Have a look at ASP.NETs Request object:

i.e.:
NavigateUrl='<%=Request.RawUrl%>'





...或导航到另一个传递查询字符串参数的页面



... or to navigate to another page passing the querystring parameters

NavigateUrl='<%=string.concat("Welcome.aspx?", Request.QueryString)%>'





希望这有帮助。



Hope this helps.


这篇关于将查询参数添加到NavigateURL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆