Hi,
I have the below modalpopupextender in a usercontrol on a site. When I run the code in development environment all runs fine. When clickin on the Submit button the modalpopupextender hides correctly. Then I publish the site and then clicking the Submit button does run the code (save in the database) but doesn't hide the panel.
Then I tried to use a javascript call instead of the mpeNewMessage.Hide() function but get the following error in development:
"Microsoft JScript runtime error: Unable to get value of the property 'hide': object is null or undefined"
I can see it goes into the javascript code but goes into the catch function. My javascript function look like this:
function HideModalPopup(popupid1) { try { $find(popupid1).hide(); } catch (ex) { $find(popupid1).hide(); } }
I have two buttons in the panel - and reset and a submit button. When I run the reset button with the javascriptcode this runs correct and close the modalpopupextender but not the submit button.
I don't know how to debug in the real environment, so I cann't see what wents wrong there.
My ascx code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MessageSystem.ascx.cs" Inherits="UserControls_Messaging_MessageSystem" %><%@ register assembly="AjaxControls" namespace="AjaxControls" tagprefix="asp" %><div><asp:label id="lblMessages" runat="server" Visible="false"></asp:label><asp:UpdatePanel ID="upanMessage" runat="server" UpdateMode="Always"><ContentTemplate><asp:label id="lblInOutBox" runat="server" Visible="false" Text=""></asp:label></ContentTemplate></asp:UpdatePanel></div><asp:panel id="panMember" runat="server"> <asp:updatepanel id="Updatepanel1" runat="server" updatemode="Always" rendermode="Inline"><ContentTemplate><asp:Button id="btnShowPopup" runat="server" style="display:none" /><asp:panel id="panNewMessage" runat="server" style="display: none" width="85%" cssclass="modalPopup" EnableViewState="false"><table width="100%"><tr><td valign="top"><table><tr><td class="tdName"><asp:label id="lblPrivateMessageTo" runat="server" text="<%$ Resources:Resource, To %>"></asp:label></td><td class="tdValue"><asp:textbox id="txtPrivateMessageTo" runat="server" width="380"></asp:textbox></td></tr><tr><td class="tdName"><asp:label id="lblPrivateMessageSubject" runat="server" text="<%$ Resources:Resource, Subject %>"></asp:label></td><td class="tdValue"><asp:textbox id="txtPrivateMessageSubject" runat="server" width="380"></asp:textbox></td></tr><tr><td valign="top" class="tdName"><asp:label id="lblPrivateMessageForm" runat="server" text="<%$ Resources:Resource, Message %>"></asp:label></td><td class="tdValue"><table width="100%"><tr><td valign="top"><asp:textbox id="txtMessage" runat="server" columns="70" rows="5" textmode="MultiLine"></asp:textbox></td><td valign="top"></td></tr></table></td></tr> </table></td><td valign="top"><div><asp:button id="btnSubmit" cssclass="button" text='<%$ Resources:Resource, Send %>' runat="server" OnClick="btnSubmit_Click" /><br /><asp:button id="btnReset" cssclass="button" text="<%$ Resources:Resource, Reset %>" runat="server" causesvalidation="false" OnClick="btnReset_Click" /><br /></div></td></tr></table><p align="center"><asp:button id="btnNewMessageClose" cssclass="button" text='<%$ Resources:Resource, Close %>' runat="server" causesvalidation="false" /></p></asp:panel><ajaxtoolkit:modalpopupextender id="mpeNewMessage" BehaviorID="NewMessageBehaviorID" runat="server" backgroundcssclass="modalBackground" targetcontrolid="btnShowPopup" popupcontrolid="panNewMessage" cancelcontrolid="btnNewMessageClose" /> </ContentTemplate></asp:updatepanel><asp:updatepanel id="upanContent" runat="server" updatemode="Always" rendermode="Inline"><contenttemplate><table width="100%"><tr><td valign="top"><Container:conTemp id="conTempMessageSystem" runat="server" allowexpandcollapse="true"><titletemplate><asp:label id="lblMessageSystemTitle" runat="server"></asp:label></titletemplate><bodytemplate><table width="100%"><tr><td valign="top" class="tdRight" width="30px"><asp:updatepanel id="upanButtons" runat="server" rendermode="Inline" updatemode="Always"><contenttemplate><!-- Modalupdateprogress --><table width="100%"><tr><td><asp:imagebutton id="ibtnSendMessage" runat="server" skinid="sendmessage" oncommand="SendMessage" /><br /><asp:label id="lblSendMessage" cssclass="tinyText" runat="server" text="<%$ Resources:Resource, PrivateMessage %>"></asp:label></td></tr><tr><td><asp:imagebutton id="ibtnSentItems" runat="server" skinid="sentitems" OnClick="ibtnSentItems_Click" /><br /><asp:label id="lblSentItems" cssclass="tinyText" runat="server" text="<%$ Resources:Resource, SentItems %>"></asp:label></td></tr><tr><td><asp:imagebutton id="ibtnInbox" runat="server" skinid="inbox" OnClick="ibtnInbox_Click" /><br /><asp:label id="lblInboxItems" cssclass="tinyText" runat="server" text="<%$ Resources:Resource, Inbox %>"></asp:label></td></tr><tr><td><asp:imagebutton id="ibtnDelete" runat="server" skinid="deletelink" OnClick="ibtnDelete_Click" /><br /><asp:label id="lblDelete" cssclass="tinyText" runat="server" text="<%$ Resources:Resource, Delete %>"></asp:label></td></tr></table> </contenttemplate> </asp:updatepanel> </td><td><table width="100%"><tr><td><asp:multiview id="muvMessageSystem" runat="server" activeviewindex="0"><asp:view id="listView" runat="server"><asp:updatepanel id="upanListView" runat="server" updatemode="Always" rendermode="Inline"><contenttemplate><table width="100%"><tr><td colspan="2"><asp:label id="lblMessageError1" SkinID="errorlabel" runat="server" text='<%$ Resources:Resource, MessageUserDontExists %>' Visible="false"></asp:label> <asp:label id="lblMessageError2" SkinID="errorlabel" Visible="false" runat="server" text=""></asp:label></td></tr><tr><td><asp:button id="btnFindUser" OnClick="btnFindUser_Click" cssclass="button" visible="true" text='<%$ Resources:Resource, FindUser %>' causesvalidation="false" runat="server" /><br /></td></tr><tr><td class="tdNoWrap"><table id="tabPageSize" runat="server" width="100%"><tr><td class="tdNoWrap"><asp:label id="lblPagerInfo" runat="server"></asp:label><asp:image id="Image5" runat="server" skinid="spacer" width="10px" /><asp:label id="lblItemsPerPage" runat="server" text="<%$ Resources:Resource, ItemsPerPage %>"></asp:label><asp:dropdownlist id="ddlPageSize" runat="server" autopostback="true"></asp:dropdownlist></td><td align="right"><asp:imagebutton id="ibtnRefresh" runat="server" skinid="refresh" OnClick="ibtnRefresh_Click" /></td></tr></table></td></tr><tr><td class="tdKBInfo"><asp:panel id="panPagingTop" runat="server"><asp:linkbutton id="lbtnTopPrev" runat="server" cssclass="pageLink" onclick="GoToPrevious" text="<%$ Resources:Resource, Previous %>"></asp:linkbutton> <asp:repeater id="repPagesTop" runat="server"><itemtemplate><asp:linkbutton id="lbtnPageTop" runat="server" commandargument="<%# Container.DataItem %>" commandname="Page" cssclass="pageLink" text="<%# BoldPageNumber(Container.DataItem.ToString()) %>"></asp:linkbutton> </itemtemplate></asp:repeater><asp:linkbutton id="lbtnTopNext" runat="server" cssclass="pageLink" onclick="GoToNext" text="<%$ Resources:Resource, Next %>"></asp:linkbutton> </asp:panel></td></tr></table><asp:panel id="panResultsGridFrame" cssclass="framePanel" runat="server" scrollbars="Auto" height="100%"><table class="gridOuterTable"><tr><td><asp:gridview id="grdResults" runat="server" PageSize="500" skinid="gridMain" cellspacing="1" autogeneratecolumns="False" allowpaging="True" allowsorting="True" pagersettings-visible="false" OnSorting="grdResults_Sorting" OnRowDataBound="grdResults_RowDataBound"><columns><asp:templatefield headertext="<%$ Resources:Resource, SelectAll %>"><headertemplate><input id="cbxCheckAll" class="cbxCheckAll" runat="server" type="checkbox" /></headertemplate><itemtemplate><asp:CheckBox ID="cbxSelect" runat="server" /></itemtemplate></asp:templatefield><asp:templatefield visible="false"><itemtemplate><asp:label id="lblMessageID" runat="server" visible="false" text='<%# Eval("privateMessageId")%>'></asp:label></itemtemplate></asp:templatefield><asp:templatefield visible="false"><itemtemplate><asp:label id="lblReadDate" runat="server" visible="false" text='<%# Eval("readDate")%>'></asp:label></itemtemplate></asp:templatefield><asp:templatefield headertext="<%$ Resources:Resource, Message %>"><itemtemplate><asp:imagebutton id="ibtnViewMessage" runat="server" oncommand="LoadMessage" commandargument='<%# Eval("privateMessageId")%>'></asp:imagebutton></itemtemplate></asp:templatefield><asp:templatefield headertext="<%$ Resources:Resource, To %>" sortexpression="UserIdTo"><itemtemplate><a href='<%# String.Format("{0}.aspx?pid=cp_profileviewer&userid={1}", AppPage, UserName(Eval("UserIdTo").ToString().Trim()))%>'><%#UserName(Eval("UserIdTo").ToString().Trim())%></a></itemtemplate></asp:templatefield><asp:templatefield headertext="<%$ Resources:Resource, From %>" sortexpression="UserIdTo"><itemtemplate><a href='<%# String.Format("{0}.aspx?pid=cp_profileviewer&userid={1}", AppPage, UserName(Eval("UserIdFrom").ToString().Trim()))%>'><%#UserName(Eval("UserIdFrom").ToString().Trim())%></a></itemtemplate></asp:templatefield><asp:boundfield datafield="subject" headertext="<%$ Resources:Resource, Subject %>" sortexpression="subject" /><asp:boundfield datafield="sendDate" headertext="<%$ Resources:Resource, DateSent %>" sortexpression="sendDate" /><asp:boundfield datafield="moderatorName" headertext="<%$ Resources:Resource, Moderator %>" sortexpression="moderatorName" Visible="false" /></columns></asp:gridview></td></tr><tr><td></td></tr></table></asp:panel><table width="100%"><tr><td><asp:panel id="panPagingBottom" runat="server"><asp:linkbutton id="lbtnBottomPrev" runat="server" cssclass="pageLink" onclick="GoToPrevious" text="<%$ Resources:Resource, Previous %>"></asp:linkbutton> <asp:repeater id="repPagesBottom" runat="server"><itemtemplate><asp:linkbutton id="lbtnPageBottom" runat="server" commandargument="<%# Container.DataItem %>" commandname="Page" cssclass="pageLink" text="<%# BoldPageNumber(Container.DataItem.ToString()) %>"></asp:linkbutton> </itemtemplate></asp:repeater><asp:linkbutton id="lbtnBottomNext" runat="server" cssclass="pageLink" onclick="GoToNext" text="<%$ Resources:Resource, Next %>"></asp:linkbutton> </asp:panel></td></tr></table></contenttemplate></asp:updatepanel></asp:view><asp:view id="viewMessage" runat="server"><asp:updatepanel id="upanMessageView" runat="server" updatemode="Always" rendermode="Inline"><contenttemplate> <table width="99%" cellpadding="0px" cellspacing="0px"><tr><td><div style="vertical-align: top;"><asp:imagebutton id="ibtnReply" runat="server" skinid="reply" OnClick="ibtnReply_Click" /><asp:label id="lblReply" runat="server" cssclass="tinyText" text="<%$ Resources:Resource, Reply %>"></asp:label> |<asp:imagebutton id="ibtnDeleteMessage" runat="server" skinid="deletesmall" OnClick="ibtnDeleteMessage_Click" /><asp:label id="lblDeleteMessage" runat="server" cssclass="tinyText" text="<%$ Resources:Resource, Delete %>"></asp:label><asp:imagebutton id="ibtnModeratorResponsible" runat="server" skinid="moderatorResponsible" OnClick="ibtnModeratorResponsible_Click" /><asp:label id="lblModeratorResponsible" runat="server" cssclass="tinyText" text="<%$ Resources:Resource, ModeratorResponsible %>"></asp:label></div></td></tr><tr><td><br /></td></tr></table><table width="99%" class="messageOuterTable" cellpadding="0px" cellspacing="0px"><tr><td><table width="100%" class="messageInnterTable" cellpadding="0px" cellspacing="0px"><tr><td><table><tr><td><asp:label font-bold="true" id="lblPrivateMessageFrom" runat="server" text="<%$ Resources:Resource, From %>"></asp:label></td><td><asp:label id="lblPrivateMessageFromDisplay" runat="server"></asp:label><asp:label id="lblPrivateMessageFromMessageId" runat="server" Visible="false"></asp:label></td></tr><tr><td><asp:label font-bold="true" id="lblPrivateMessageSubject2" runat="server" text="<%$ Resources:Resource, Subject %>"></asp:label></td><td><asp:label id="lblPrivateMessageSubjectDisplay" runat="server"></asp:label></td></tr></table><table width="100%"><tr><td><hr /></td></tr></table><asp:panel id="panMessageViewFrame" runat="server" scrollbars="Auto" height="325px"><table width="98%"><tr><td><asp:label cssclass="spanWrap" id="lblPrivateMessageDisplay" runat="server"></asp:label></td></tr></table></asp:panel></td></tr></table></td></tr></table> </contenttemplate></asp:updatepanel> </asp:view></asp:multiview></td></tr></table></td></tr></table></bodytemplate></Container:conTemp></td></tr></table></contenttemplate></asp:updatepanel><asp:textbox id="txtPMTo" runat="server" Width="0px"></asp:textbox></asp:panel>
My two buttons code and the code to save in the database (It saves into the database so I don't think the error is in here):
protected void btnSubmit_Click(object sender, System.EventArgs e) { SendMessages(); ClearTextBoxes(); txtPrivateMessageTo.Text = string.Empty; txtPMTo.Text = string.Empty; panNewMessage.Visible = false; mpeNewMessage.Hide(); //ScriptManager.RegisterStartupScript(btnReset, this.GetType(), "HideModalPopup", "HideModalPopup('NewMessageBehaviorID')", true); } protected void btnReset_Click(object sender, System.EventArgs e) { ClearTextBoxes(); txtPrivateMessageTo.Text = string.Empty; txtPMTo.Text = string.Empty; panNewMessage.Visible = false; mpeNewMessage.Hide(); //ScriptManager.RegisterStartupScript(btnReset, this.GetType(), "HideModalPopup", "HideModalPopup('NewMessageBehaviorID')", true); } private void SendMessages() { HideMessages(); string privateMessageTo = txtPrivateMessageTo.Text.ToString().Trim(); privateMessageTo = privateMessageTo.Replace(" ", ""); string[] ToList = privateMessageTo.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); foreach (string name in ToList) { string userId = UserIdByUserName(name); if (userId != "") { char? emtyChar = null; char[] specialBeginningChars = new char[] { ',', Convert.ToChar(emtyChar) }; if (UserExists(UserIdByUserName(name))) { SendPrivateMessage(UserIdByUserName(name), CurrentUserId, txtPrivateMessageSubject.Text.TrimStart(specialBeginningChars), txtMessage.Text.TrimStart(specialBeginningChars)); } } else { lblMessageError1.Visible = true; lblMessageError2.Text += name + ", "; lblMessageError2.Visible = true; } } //SendPrivateMessage(UserIdByUserName(txtPrivateMessageTo.Text), CurrentUserId, txtPrivateMessageSubject.Text, txtMessage.Text); }
I hope someone can help me :-)
Kind regards,
simsen :-)