Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 375131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:28:22+00:00 2026-05-12T14:28:22+00:00

Trying to pop up an IFrame Shadowbox with Jquery from an asp:gridview datarow. I

  • 0

Trying to pop up an IFrame Shadowbox with Jquery from an asp:gridview datarow. I can’t get the proper quotes into the string:

<asp:ImageButton ID="btnEdit" runat="server"
    OnClientClick='<%# "javascript:popAccount(\'"+ 
    Eval("id", "Popup.aspx?id={0}")+"\');" %>' />

Parser Error Message: The server tag is not well formed.

Without the escaped single quotes (cannot work, but parses properly):

<asp:ImageButton ID="btnEdit" runat="server"
    OnClientClick='<%# "javascript:popAccount("+ 
    Eval("id", "Popup.aspx?id={0}")+");" %>' />

Client-side HTML, as expected:

onclick="javascript:popAccount(Popup.aspx?id=3ce3b19c-1899-4e1c-b3ce-55e5c02f1);"

How do I get quotes into the Javascript?

Edit: added solution. This not very generic, since the databound types must be known in order to access the id property. The key (as defined in the GrodView’s DataKeyNames parameter) does not seem to be exposed in the event argument. But it works.

    protected void editGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        // do not look at header or footer
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            ImageButton btn = e.Row.FindControl("btnPopup") as ImageButton;
            if (btn != null)
            {
                btn.OnClientClick = 
                "javascript:popAccount('EditAccountPopup.aspx?"+
                Constants.acctidParam+"="+
                ((tb_account)(e.Row.DataItem)).id.ToString()+"');";
            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:28:22+00:00Added an answer on May 12, 2026 at 2:28 pm

    Pick up the ImageButton in the GridView’s rowdatabound event in the codebehind, and add the property from there.

    But are you sure you need to use a server control? How about just a plain image? If you’re “replacing” the click-behaviour of the ImageButton, it doesn’t seem like you need it at all.

    Update:

    For the code-behind solution, I coded up this little sample (in VB.NET, sorry):

      Private Sub gridview1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gridview1.RowDataBound
        Select Case e.Row.RowType
          Case DataControlRowType.DataRow
            Dim btnEdit As ImageButton = CType(e.Row.Cells(0).FindControl("btnEdit"), ImageButton)
            Dim strID As String = CType(e.Row.DataItem, Guid).ToString
    
            btnEdit.Attributes.Add("onclick", String.Format("javascript:popAccount('Popup.aspx?id={0}');", strID))
        End Select
      End Sub
    

    However, I’d still recommend you go with a simpler aproach, jQuery is excellent here. No
    need for any code in your codebehind:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
      <title></title>
    
      <script src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.3.2.min.js" type="text/javascript"></script>
    
      <script type="text/javascript" language="javascript">
        $(document).ready(function() {
    
          $("img.edit").click(function() {
            var sID = this.id.replace('btnEdit_', '');
            alert(sID); // Add your popup opening logic here...
          });
        });
      </script>
    
    </head>
    <body>
      <form id="form1" runat="server">
      <div>
        <asp:GridView ID="gridview2" AutoGenerateColumns="false" runat="server">
          <Columns>
            <asp:TemplateField>
              <ItemTemplate>
                <img id="btnEdit_<%#Container.DataItem %>" class="edit" />
              </ItemTemplate>
            </asp:TemplateField>
          </Columns>
        </asp:GridView>
      </div>
      </form>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to format some bad html to output into a pop window.
I am trying to add a link into the pop-up text bubble of a
I'm trying to pop a simple datepicker but can't or I don't know what
I am trying to pop up dialog from run method it gives me exception
I'm trying to pop a window up, from inside a procedure running in SharePoint.
I'm stuck trying to pop a TTPhotoViewController from three20. At first it did not
I'm trying to have text spans pop up on a hover pseudo-class for different
Trying to get my css / C# functions to look like this: body {
Trying to make a make generic select control that I can dynamically add elements
Trying to make a MySQL-based application support MS SQL, I ran into the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.