Solved

How to pass parameters to java script function from OnClient Click(from the Link button in DataGrid)

Posted on 2013-01-30
4
620 Views
Last Modified: 2013-02-20
Hi,
I am trying  to pass parameters to java script function from OnClient Click(from the Link button in DataGrid).It is giving me the error in the grid generation itself.The error is
Server tag is not well formed.

Please see the DataGrid source and JavaScript function.

<ASP:DATAGRID id="DGrid" runat="server"  ShowFooter="False"
                        AutoGenerateColumns="False" BorderWidth="2" cellspacing="0" cellpadding="3" HeaderStyle-CssClass="TableHeaders"
                        EnableViewState="True" >
             
                        <Columns>
                <asp:TemplateColumn HeaderText="Number">
     
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkNumber" runat="server" CausesValidation="false" OnClientClick="openmodaldialog2(document.getElementById(" + '<%#("lnkNumber.ClientID") %>' + ");" Text='<%# DataBinder.Eval(Container, "DataItem.ID") %>' readonly="True"></asp:LinkButton>
                         
                         </ItemTemplate>
                        <HeaderStyle Width="200px" />
                 </asp:TemplateColumn>
                              
                              <ASP:BoundColumn HeaderStyle-Width="50px" HeaderText="Name" DataField="Name" readonly="True" />
                              <ASP:BoundColumn HeaderStyle-Width="100px" HeaderText="Address" DataField="Address""
                                    readonly="True" />
                              <ASP:BoundColumn HeaderStyle-Width="100px" HeaderText="State" DataField="State"
                                    readonly="True" />
                              <ASP:BoundColumn HeaderStyle-Width="100px" HeaderText="Zip" DataField="Zip"
                                     readonly="True" />
                        </Columns>
                  </ASP:DATAGRID>

 function openmodaldialog2(Num)
     {
         myPopUp2 = window.showModalDialog("Page1.aspx", "", "dialogHeight: 350px;dialogWidth: 650px;status:no;")
       
        return false;
    }
if there is no OnClienClick() event the Grid is populating fine.
Any suggestion for passing the parameres from OnClientClick event in the DataGrid.

Thanks.
0
Comment
Question by:KavyaVS
4 Comments
 
LVL 41

Assisted Solution

by:guru_sami
guru_sami earned 150 total points
ID: 38837529
So you want to pass the ID of the linkButton to your js function or some other value from your Data?
Do you need a LinkButton or can a regular link would work?
e.g. say you want to pass some column value to your function it would look something like:

<a onclick="openmodaldialog2('<%# Eval("ID") %>');" href="#"><%# Eval("ID") %></a>

Open in new window

0
 
LVL 29

Accepted Solution

by:
Kumaraswamy R earned 200 total points
ID: 38838439
0
 
LVL 1

Assisted Solution

by:jinsonaf
jinsonaf earned 150 total points
ID: 38838728
0
 

Author Closing Comment

by:KavyaVS
ID: 38908587
Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question