Solved

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

Posted on 2013-01-30
4
624 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

752 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