Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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.NET
<asp:TemplateField ShowHeader="False">
<itemtemplate>
  <asp:LinkButton ID="linkNew" CausesValidation="false" CommandName=""runat="server" Text="New Tx">
</itemtemplate>

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:

JavaScript
function ShowEditModal(LocatorID) {
                 var frame = $get('IframeEdit');
                 frame.src = "Receive.aspx?UIMODE=NEW&EID=" + LocatorID;
                 $find('EditModalPopup').show();
             }


Finally the IframeEdit
HTML
<div id="DivEditWindow" style="display: none;" class="popupConfirmation">
                <iframe id="IframeEdit" frameborder="0" scrolling="no" height="400" width ="600">
                </iframe>
            </div>


The code in Receive.aspx page is this
C#
public enum UIMODE
    {
        NEW,
        EDIT,
        VIEW
    }
    public partial class Receive : System.Web.UI.Page
    {
        public UIMODE UIMode
        {
            get
            {
                if (ViewState["UIMODE"] == null)
                    ViewState["UIMODE"] = new UIMODE();
                return (UIMODE) ViewState["UIMODE"] ;
            }
            set
            {
                ViewState["UIMODE"] = value;
            }
        }

        private string EID
        {
            get
            {
                string text = (string)ViewState["EID"];
                if (text != null)
                    return text;
                else
                    return string.Empty;
            }
            set
            {
                ViewState["EID"] = value;
            }
        }
 protected void Page_Load(object sender, EventArgs e)
        {
            //Response.Cache.SetCacheability(HttpCacheability.NoCache);
           
            if (!IsPostBack)
            {
                Validate();
                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
Updated 6-Sep-12 6:02am
v2
Comments
Ryanm1324 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900