Multi-parameter query string in hyperlink column...

S

Steve Kallal

I have found some postings on multi-parameter hyperlinks. But none of them involve calling a javascript function. I have almost got the NavigateUrl property to work, but not quite. Here is the DataGrid definition

<asp:DataGrid id="grid" runat="server" Width="99%" AutogenerateColumns="false" AllowPaging="True
AllowCustomPaging="True"><AlternatingItemStyle CssClass="datagrid_alternating_item"></AlternatingItemStyle><ItemStyle CssClass="datagrid_item"></ItemStyle><HeaderStyle CssClass="tableheader" BackColor="SteelBlue"></HeaderStyle><Columns><asp:TemplateColumn><ItemTemplate><asp:HyperLink id=lnkID runat="server" NavigateUrl='<%# "javascript:ShowForm(accountID=" & Server.UrlEncode(Container.DataItem("AccountKey")) & "&LDCID=" & Server.UrlEncode(Container.DataItem("LDCID")) & ")" %>
text='<%#Container.DataItem("RowNum")%>'></asp:HyperLink></ItemTemplate></asp:TemplateColumn></Columns><PagerStyle HorizontalAlign="Right" Position="TopAndBottom" CssClass="field" Mode="NumericPages"></PagerStyle></asp:DataGrid

I am able to get the hyperlink URL at runtime set to

javascript:ShowForm(accountID=267425&LDCID=SCE

But what I really need is

javascript:ShowForm('accountID=267425&LDCID=SCE'

The single quote characters surrounding the parameter to the ShowForm Javascript function is a real annoyance. How do I do this without resorting to code of the ItemDataBound event

Thanks in advance
 
M

Michael Tkachev

Hi,

try to write like this - '''

For example:

NavigateUrl='<%# "javascript:ShowForm('''accountID=" &
Server.UrlEncode(Container.DataItem("AccountKey")) & "&LDCID=" &
Server.UrlEncode(Container.DataItem("LDCID")) & ")''" %>'



Steve Kallal said:
I have found some postings on multi-parameter hyperlinks. But none of them
involve calling a javascript function. I have almost got the NavigateUrl
property to work, but not quite. Here is the DataGrid definition:
<asp:DataGrid id="grid" runat="server" Width="99%"
AutogenerateColumns="false" AllowPaging="True"
AllowCustomPaging="True"><AlternatingItemStyle
CssClass="datagrid_alternating_item"></AlternatingItemStyle><ItemStyle
CssClass="datagrid_item"></ItemStyle><HeaderStyle CssClass="tableheader"
BackColor="SteelBlue"></HeaderStyle><Columns><asp:TemplateColumn><ItemTempla
te><asp:HyperLink id=lnkID runat="server" NavigateUrl='<%#
"javascript:ShowForm(accountID=" &
Server.UrlEncode(Container.DataItem("AccountKey")) & "&LDCID=" &
Server.UrlEncode(Container.DataItem("LDCID")) & ")" %>'text='<%#Container.DataItem("RowNum")%>'></asp:HyperLink></ItemTemplate></as
p:TemplateColumn></Columns><PagerStyle HorizontalAlign="Right"
Position="TopAndBottom" CssClass="field"
Mode="NumericPages"> said:
I am able to get the hyperlink URL at runtime set to:

javascript:ShowForm(accountID=267425&LDCID=SCE)

But what I really need is:

javascript:ShowForm('accountID=267425&LDCID=SCE')

The single quote characters surrounding the parameter to the ShowForm
Javascript function is a real annoyance. How do I do this without resorting
to code of the ItemDataBound event.
 
S

Steven Cheng[MSFT]

Hi Steven,

As for the problem on the quotes in DataBind experssion in VS.NET when
switch from htmlview to design view, it's a known behavior. We can use the
following experssion syntax to overcome it:

<asp:HyperLinkColumn NavigateUrl='<%# "javascript:ShowForm("""accountID=" +
DataBinder.Eval(Container.DataItem,"index") + """")" %>'>

use """ to represent the quote between the upper level quote

In addition, here is a former thread discussing the same problem and you
can also find the solution in it:

#problem with quotes in vs.net
http://groups.google.com/groups?hl=zh-CN&lr=&ie=UTF-8&oe=UTF-8&threadm=BR0Cu
lJxDHA.1272%40cpmsftngxa07.phx.gbl&rnum=3&prev=/groups%3Fhl%3Dzh-CN%26lr%3D%
26ie%3DUTF-8%26oe%3DUTF-8%26q%3Dquote%2Bsteven%2Bcheng

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
S

Steven Cheng[MSFT]

Hi Steve,

Have you had a chance to check out the suggestions in my last reply or have
you got any further ideas on this issue? If you have anything unclear or if
there're anything else we can help, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top