Multi-parameter query string in hyperlink column...

Multi-parameter query string in hyperlink column...

Post by U3RldmUgS2 » Wed, 28 Apr 2004 09:51:04


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
 
 
 

Multi-parameter query string in hyperlink column...

Post by Michael Tk » Wed, 28 Apr 2004 16:23:22

Hi,

try to write like this - '''

For example:

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





involve calling a javascript function. I have almost got the NavigateUrl
property to work, but not quite. Here is the DataGrid definition:
AutogenerateColumns="false" AllowPaging="True"
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"></PagerStyle></asp:DataGrid>
Javascript function is a real annoyance. How do I do this without resorting
to code of the ItemDataBound event.

 
 
 

Multi-parameter query string in hyperlink column...

Post by v-schan » Wed, 28 Apr 2004 19:43:54

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://www.yqcomputer.com/
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://www.yqcomputer.com/
 
 
 

Multi-parameter query string in hyperlink column...

Post by v-schan » Fri, 30 Apr 2004 17:48:48


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://www.yqcomputer.com/