Solved

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

Posted on 2013-01-30
4
610 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now