Multi-parameter query string in hyperlink column...

Discussion in 'ASP .Net Datagrid Control' started by Steve Kallal, Apr 27, 2004.

  1. Steve Kallal

    Steve Kallal Guest

    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
     
    Steve Kallal, Apr 27, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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"></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!
    >
     
    Michael Tkachev, Apr 27, 2004
    #2
    1. Advertising

  3. 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
     
    Steven Cheng[MSFT], Apr 27, 2004
    #3
  4. 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
     
    Steven Cheng[MSFT], Apr 29, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?V2FyYW4=?=

    HyperLink Column and Button Column in a DataGrid

    =?Utf-8?B?V2FyYW4=?=, Aug 9, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    626
    =?Utf-8?B?V2FyYW4=?=
    Aug 9, 2005
  2. davetichenor
    Replies:
    1
    Views:
    907
    Eliyahu Goldin
    Oct 30, 2006
  3. Carl Howarth

    Hyperlink Template Column w Query String

    Carl Howarth, Jul 24, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    160
    Carl Howarth
    Jul 24, 2003
  4. Elton Wang
    Replies:
    0
    Views:
    133
    Elton Wang
    Mar 31, 2005
  5. Dave
    Replies:
    0
    Views:
    997
Loading...

Share This Page