Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-01-30
4
Medium Priority
?
636 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 450 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 600 total points
ID: 38838439
0
 
LVL 1

Assisted Solution

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

Author Closing Comment

by:KavyaVS
ID: 38908587
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…
Suggested Courses

824 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