Problemer med hide funktionen i modulpopupextender
Hej,Jeg er temmelig desperat og har knoklet hele dagen i går for at løse mit problem;
På min maskine når jeg kører en side, virker modulpopupextender ganske fint. Jeg åbner og sætter noget tekst ind og klikker så på en af 2 knapper (gem) og den gemmer i databasen og lukker pænt modulpopupextender igen. Nu har jeg så uploadet siden til produktion (på unoeuro og har dermed ikke kontrol med web-serveren og aner ikke hvordan jeg kan debugge der) og nu virker min popupextender ikke længere. Den åbner pænt og gemmer også i databasen men lukker ikke extenderen igen.
Så troede jeg det var selve mpeNewMessage.Hide(); den ikke kunne lide, så jeg forsøgte mig med en javascript i stedet;
ScriptManager.RegisterStartupScript(btnReset, this.GetType(), "HideModalPopup", "HideModalPopup('NewMessageBehaviorID')", true);
koden til denne:
function HideModalPopup(popupid1) {
try {
$find(popupid1).hide();
}
catch (ex) {
$find(popupid1).hide();
}
}
Her fejler den dog på min udviklingsmaskine (men lukker alligevel extenderen). Den går ind i catch delen på javascript funktionen.
Når jeg så uploader, så kører det med den ene knap...Reset (som bare gør tekstfelterne tomme og lukker extenderen) men stadig ikke på min Gem knap. Den forbliver åben.
Jeg har forsøgt at sætte en label ind - for at se om den fanger gem delen til databasen men denne bliver ikke opdateret.
Det skal siges - bruger jeg Luk knappen på min extender i produktion så lukker den pænt extenderen.
Selve gemningen til databasen forløber fint. Ingen fejl der.
Et eller andet sted, så tror jeg, det måske slet ikke er extenderen men måske mine update panels på siden. Jeg forstår det dog ikke, da jeg har sat dem alle til updatemode="Always" og rendermode="Inline".
Jeg håber, en eller anden kan hjælpe mig, da jeg er lidt desperat. Vil være ked af at skulle programmere hele l.... om og undlade extenderen :-)
mvh
simsen
Min aspx kode:
<%@ 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>
<tr>
<td colspan="2">
<asp:Label ID="lblTest" runat="server" Text="XXXXXX"></asp:Label>
</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>
-------------------------------------
Min cs kode for de to knapper:
protected void btnSubmit_Click(object sender, System.EventArgs e)
{
SendMessages();
try
{
ClearTextBoxes();
txtPrivateMessageTo.Text = string.Empty;
txtPMTo.Text = string.Empty;
panNewMessage.Visible = false;
mpeNewMessage.Hide();
//ScriptManager.RegisterStartupScript(btnReset, this.GetType(), "HideModalPopup", "HideModalPopup('NewMessageBehaviorID')", true);
}
catch(Exception ex)
{
lblTest.Text = ex.ToString();
}
}
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)))
{
try
{
SendPrivateMessage(UserIdByUserName(name), CurrentUserId, txtPrivateMessageSubject.Text.TrimStart(specialBeginningChars), txtMessage.Text.TrimStart(specialBeginningChars));
lblTest.Text = "Message sent close window";
}
catch(Exception ex)
{
lblTest.Text = ex.ToString();
}
}
}
else
{
lblMessageError1.Visible = true;
lblMessageError2.Text += name + ", ";
lblMessageError2.Visible = true;
}
}
//SendPrivateMessage(UserIdByUserName(txtPrivateMessageTo.Text), CurrentUserId, txtPrivateMessageSubject.Text, txtMessage.Text);
}