Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET Ajax
I am having an issue with opening a modalextender which contains a window from clicking on an ASP LinkButton on a gridview. I need to pass a value from the row to the modal page I am showing.
Here is my code for the link button in my gridview.
<asp:TemplateField ShowHeader="False">
  <asp:LinkButton ID="linkNew" CausesValidation="false" CommandName=""runat="server" Text="New Tx">
I have 
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
        if (e.Row.RowType == DataControlRowType.DataRow)
        (e.Row.FindControl("linkNew") as LinkButton).Attributes.Add("onclick", "ShowEditModal('" + (e.Row.FindControl("lbLocator") as Label).Text + "');");
The Javascript is:
 function ShowEditModal(LocatorID) {
                  var frame = $get('IframeEdit');
                  frame.src = "Receive.aspx?UIMODE=NEW&EID=" + LocatorID;
Finally the IframeEdit
<div id="DivEditWindow" style="display: none;" class="popupConfirmation">
                <iframe id="IframeEdit" frameborder="0" scrolling="no" height="400" width ="600">
The code in Receive.aspx page is this
public enum UIMODE
    public partial class Receive : System.Web.UI.Page
        public UIMODE UIMode
                if (ViewState["UIMODE"] == null)
                    ViewState["UIMODE"] = new UIMODE();
                return (UIMODE) ViewState["UIMODE"] ;
                ViewState["UIMODE"] = value;
        private string EID
                string text = (string)ViewState["EID"];
                if (text != null)
                    return text;
                    return string.Empty;
                ViewState["EID"] = value;
 protected void Page_Load(object sender, EventArgs e)
            if (!IsPostBack)
                string qsUIMODE = Request.QueryString["UIMODE"];
                if (string.IsNullOrEmpty(qsUIMODE) == false)
                    UIMode = (UIMODE)Enum.Parse(typeof(UIMODE), qsUIMODE);
                    EID = Request.QueryString["EID"];
                    hdnWindowUIMODE.Value = UIMode.ToString();
                MultiViewReceive.ActiveViewIndex = 1;
I can see the window popup correctly when the linkbutton is clicked, but it then dissapears right away and I need it to stay on the page.
Any help would be great. Please let me know if anything else is needed from my code as well.
Posted 6-Sep-12 7:00am
Edited 6-Sep-12 7:02am
(no name)94.3K
Ryanm1324 at 6-Sep-12 14:58pm
This seems to run the page_load event twice and on the second one qsUIMODE is NULL. The modal window then closes, but I need it to be open

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 7,205
1 DamithSL 5,114
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,747
4 Kornfeld Eliyahu Peter 4,474

Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 6 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100