how to use update panel with model extender popup - asp.net

I have a link on update panel,when i clicked on Cure Loan,model extender pop up should come up but instead of one popup all the popup on the page is come up
so please give me the solution how to use update panel with model extender pop up
here is my code
<asp:UpdatePanel ID="UPCureLoan" runat="server">
<ContentTemplate>
<td style="border: 0.5px solid #000000; border-collapse: separate; height: 44px;" bgcolor="#CCCCCC">
<asp:Label ID="CFMessage" runat="server" Visible="False"></asp:Label>
<br />
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">Cure Loan</asp:LinkButton>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="LinkButton2" EventName="click" />
</Triggers>
Panel->
<table style="width: 100%; background-color: #DDE2E5;">
<tr style="background-color: #522E8B; color: white; height: 50px">
<td colspan="4" style="text-align: center; font-size: medium"><b>Notification</b></td>
</tr>
<tr>
<td>
<br />
<br />
</td>
</tr>
<tr>
<td colspan="3" style="font-size: medium;"> I confirm that I have discussed the borrowers concerns with the borrower.<br />
Please enter your initials to confirm
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<br />
<br />
</td>
</tr>
<tr>
<td></td>
<td colspan="3" style="text-align: center">
<asp:CheckBox ID="CheckBox4" runat="server" Style="transform: scale(2) !important;" Height="20px" Width="20px" /><b> Resend Borrower Survey 1 </b></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr style="text-align: center">
<td> </td>
<td>
<td>
<asp:Button ID="Button4" runat="server" Text="Close" Height="30px" Width="120px" />
<asp:Button ID="Button5" OnClick="popupConfirm1" runat="server" Text="Confirm" Height="30px" Width="120px" /></td>
</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<%-- <cc1:CalendarExtender ID="CalendarExtender2" TargetControlID="TXTDate" Format="MM/dd/yyyy" runat="server" />--%>
</asp:Panel>
Model extender Popup->
ID="Modalpopupextender5" runat="server"
PopupControlID="Panel5" TargetControlID="hidForModel"
BackgroundCssClass="gridView" OkControlID="ButtonSave">
</cc1:ModalPopupExtender>

You are not using the UpdatePanel control properly.
All you're doing there is placing some HTML code (which is incorrect) inside the ContentTemplate.
<ContentTemplate>
<%-- Where is your <table> etc? --%>
<td style="border: 0.5px solid #000000; border-collapse: separate; height: 44px;" bgcolor="#CCCCCC">
<asp:Label ID="CFMessage" runat="server" Visible="False"></asp:Label>
<br />
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">Cure Loan</asp:LinkButton>
</ContentTemplate>
You also have your other code outside of the UpdatePanel.
All your code that has to be controlled by the Panel and the modalpopup, must be inside the UpdatePanel. BUT your ModalPopupExtender itself can be outside the UpdatePanel. In fact, it should if you're treating the UpdatePanel as a "popup box".
This is how I use UpdatePanels with AJAX:
Firstly set up your styles for the background, the panels and the popup itself.
<style type="text/css">
.pnlCIR
{
position: absolute; top: 20%; left: 22%; width: 400px; border: 3px solid LightSlateGray;
background-color: #E0E8F0; padding: 3px; font-family: Arial; font-size: small;
}
.modalBackground
{
background-color:Gray;
filter:alpha(opacity=70);
opacity:0.7;
position:fixed;
overflow:hidden;
}
</style>
Next define your AJAX popup:
<asp:Button ID="btnCIR" runat="server" Text="Suggest Improvement (CIR)" CausesValidation="false" />
<ajaxToolkit:ModalPopupExtender ID="mpeCIR" runat="server"
BackgroundCssClass="modalBackground"
PopupControlID="upCIR"
TargetControlID="btnCIR">
</ajaxToolkit:ModalPopupExtender>
Next define your UpdatePanel as a "wrapper" around your code that you want to be inside the panel (in my case the "CIR" panel)
<asp:UpdatePanel ID="upCIR" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlCIR" runat="server" CssClass="pnlCIR" Width="700px">
<your code>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
Note:
You must use UpdateMode conditional
You must have a Panel inside the UpdatePanel, so that the Panel is the actual popup, and the UpdatePanel is the control that keeps postbacks inside the UpdatePanel, avoiding the dread "postback flash" on your entire screen.

Related

Internet Exporer 11 rendering table improperly

on my page I have a table with a few elements in it, but it messes up in Internet Explorer 11. Any help appreciated
Here is what it looks like in VS:
In Chrome:
And here IE:
My Code:
<table>
<tr>
<td style="width: 50%; text-align: left"><br /><br /><br />
<asp:Label ID="lbl_dm_rvi" runat="server" Text="sometext RVI"></asp:Label><br />
<asp:Label ID="lbl_dm_odv" runat="server" Text="sometext ODV"></asp:Label>
</td>
<td style="width: 50%; text-align: right; text">
<asp:Label ID="lbl_hochrechnung" runat="server" Text="Hochrechnung_RX_SM_KVBEZ"></asp:Label><br />
<asp:Label ID="lbl_modul1" runat="server" Text="Modul 1"></asp:Label><br />
<asp:Label ID="lbl_modul_30" runat="server" Text="Modul 3.0"></asp:Label><br />
<asp:Label ID="lbl_modul_31" runat="server" Text="Modul 3.1"></asp:Label><br />
<asp:Label ID="lbl_modul3" runat="server" Text="Modul 3"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
<img src="klammer.png" style="width: 400px"/>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<asp:Label ID="lbl_modul2" runat="server" Text="Modul 2"></asp:Label><br />
<asp:Label ID="lbl_odv" runat="server" Text="ODV"></asp:Label><br />
<asp:Label ID="lbl_modul2a" runat="server" Text="Modul 2a"></asp:Label><br />
<asp:Label ID="lbl_modul4" runat="server" Text="Modul 4"></asp:Label><br />
<asp:Label ID="lbl_modul4a" runat="server" Text="Modul 4a"></asp:Label>
</td>
</tr>
</table>
What I see at the first is that the table on IE is take the full width, the other two are not.
This is usually done because its browser did not have the same default setting for all elements.
A quick solution is to set the width on the table as
<table style="width: 300px;" >
so you not left it random.
You can also try to use any "Reset CSS" (like Eric Meyer’s) thats try to bring all browser styles to the same point.
Related: What is the easiest or fastest way to make CSS render the same in all browsers

Focus on TextBox inside TabContainer

I have a custom Login screen in a Tab Container
<asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" AutoPostBack="true" OnActiveTabChanged="TabContainer1_ActiveTabChanged" CssClass="MyTabStyle">
<asp:TabPanel ID="uxStandardTab" runat="server" HeaderText="Login">
<ContentTemplate>
<table width="320px" border="0" style="border-width: 0px;">
<tr>
<td>
<cc1:LabeledTextBox ID="Username" runat="server" Required="true" LabelText="Email/User Name" LabelWidth="120" ControlWidth="150" LabelCss="FormLabelText BoldText" ValidationGroup="Standard"></cc1:LabeledTextBox>
<cc1:LabeledTextBox ID="Password" runat="server" TextMode="Password" Required="true" LabelText="Password" LabelWidth="120" ControlWidth="150" LabelCss="FormLabelText BoldText" ValidationGroup="Standard"></cc1:LabeledTextBox>
</td>
</tr>
<tr>
<td>
<div style="margin-top: 5px; margin-right: 20px; text-align: center;">
<asp:Button ID="btnLogin" runat="server" Text="Log In" CssClass="grnbutton" OnClick="btnLogin_Click" ValidationGroup="Standard" />
</div>
</td>
</tr>
</table>
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
I'm trying to set focus on User Name field in the page load.
I have tried
var txtUserName = uxStandardTab.FindControl("UserName");
if (txtUserName != null)
{
Page.SetFocus(txtUserName);
}
and
Username.Focus();
But, none of them puts cursor in User Name Text box during page load. Please advise, if Tab Control behaves differently.
With Ajax don't use Page.SetFocus but Scriptmanager.SetFocus:
ScriptManager.GetCurrent(Page).SetFocus(txtUserName);

How to show DIV just on top of button

I have a custom control, which has a Button + image, if image(down arrow) is clicked, a DIV should display, just like Dropdownlist.
However, its pushing the page contents to down to display the DIV. How to fix this.
It should just behave like dropdown
List should display on top of Button instead button
<table id="container" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:Button ID="btnPost" runat="server" CssClass="postButton" OnClick="btnPost_Click" />
<asp:Button ID="btnDropDown" runat="server" CssClass="dropdownButton" OnClick="btnDropDown_Click" />
</td>
</tr>
<tr>
<td>
<div runat="server" id="divDropDownPanel" visible="false" style="text-align: left;
overflow: scroll; float: left; border: thin solid lightgrey; width: 160px; height: 120px;
background-color: #FFFFFF; position: absolute; z-index: 999;">
<asp:Repeater ID="rptDropDownContent" runat="server" OnItemDataBound="rptDropDownContent_ItemDataBound">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td align="left">
<asp:CheckBox ID="chkChannel" runat="server" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tr> </table>
</FooterTemplate>
</asp:Repeater>
<br />
</div>
</td>
</tr>

Comma appearing in text box and popup calendar in google chrome in ASP.net

I have a very strange problem. i have a text box and date picker inside an update panel and a button inside panel, when ever i enter some text in text box and select date and press "enter"
button event handel is called and after call back text box content copy and concate with "comma" same as the issue with date picker.
Any solution of this??
<asp:UpdatePanel ID="pnlPickIt" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="False">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnGo" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnRcpnt" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnRcpntDiffDate" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnNewOrder" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="pnlPickZip" runat="server" DefaultButton="btnGo" meta:resourcekey="pnlPickZipResource">
<table cellpadding="0" cellspacing="0" class="pickItHeading">
<tr>
<td colspan="4" class="hdgPickIt enabledl">
<table><tr><td>
<h2 style="font-size: 13px; font-weight: bold;">
<asp:Literal ID="litDivStoreFinderMessage" runat="server" meta:resourcekey="litDivStoreFinderMessageResource"></asp:Literal>
<asp:LinkButton ID="lnkShowOtherCountries" runat="server" meta:resourcekey="lnkShowOtherCountriesResource"></asp:LinkButton>
<asp:Localize ID="lclOtherCoutriesText" runat="server" meta:resourcekey="lclOtherCoutriesTextResource"></asp:Localize>
</h2>
</td>
<td>
<input type="button" id="btnAddressBook1" value='<%=Getlocalresourceobject("ResourceAddBook") %>' onclick="ShowAddressBook('<%= txtZip.ClientID %>', '<%= hdnContactID.ClientID %>', this, 'Right');" style='display: <%=IIF(Utility.Generic.IsID(CType(Session("UserSessionState"), BO.UserSessionState).UserID), "", "none") %>; width:131px; font-size:12px;' />
</td>
</tr></table>
</td>
</tr>
<tr>
<td style="width: 138px"><asp:TextBox ID="txtZip" onfocus="ZipVal=this.value;" onblur="this.value=fixZipAndPostalCode(this.value); $('[id^=dverr]').hide();ForcebtnGoClick(this.value);" CssClass="txtPickIt" Style="width: 100px" MaxLength="7" WaterMarkText='<%#GetLocalResourceObject("ZipPostalCodeWaterMarkText") %>' runat="server" meta:resourcekey="txtZipResource"></asp:TextBox></td>
<td style="width: 107px"><asp:TextBox ID="txtDate" onfocus="$('#dverr4').hide();" onblur="$('[id^=dverr]').hide();" CssClass="txtPickItCal" WaterMarkText='<%#GetLocalResourceObject("DateWaterMarkText") %>' Width="70px" runat="server" meta:resourcekey="txtDateResource"></asp:TextBox></td>
<td align="left" style="width: 55px"><asp:Button ID="btnGo" OnClientClick="$('#divZipNotFound').fadeOut();hideShipmentArrangements();HideZipFinder(); return ValidateZip();" onblur="$('#dverr4').hide();" CssClass="PickITGo" runat="server" meta:resourcekey="btnGoResource" /></td>
<td align="left" style="width:160px"><table><tr><td><a id="lnkStoreFinder" style="font-size:11px;" href="javascript:void(0);" onclick="document.getElementById('hdnZipTextBoxID').value = '<%= txtZip.ClientID %>';ShowZipFinder(this, -367);return false;"><%=GetLocalResourceObject("lclFindResource.Text").ToString.Replace("**ZipCode**", GetZipCodeTextByCountry())%></a></td><td><asp:ImageButton id="btnGoBack" runat="server" ImageUrl='<%# ImagePage & "bn/btn_goBackSmall.jpg" %>' /></td></tr></table></td>
</tr>
</table>
<div runat="server" visible="False" id="divZipState" style="position: absolute; font-size: 11px;height: 12px; color: #666666;"><asp:Literal ID="litZipState" runat="server" meta:resourcekey="litZipStateResource"></asp:Literal></div>
</asp:Panel>
<div id="dverr6" class="validatorMsgBig" style="position: absolute; display: none; height: 45px; width: 440px; padding: 5px;">
<a id="A6" href="#"><img id="img6" style="float: right; border-width: 0px;" onclick="return HideErrorMsg('dverr6');" src="<%= ImagePage %>btn_cross_l.jpg" /></a>
<table>
<tr>
<td><img src="<%= ImagePage %>icon_order_error_big_yelowbg.jpg" /></td>
<td align="left" style="padding-left: 10px;"><span style="font-family: Arial; font-size: 16px; font-weight: bold; color: #383433;"><asp:Literal ID="litErrorMsg" runat="server" meta:resourcekey="litErrorMsgResource"></asp:Literal></span></td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>

Modalpopup wont close when dropdown is selected

I've been having this odd issue with modal popups. For some reason when I choose a dropdown item my update button wont fire a click event. but then I leave the dropdown at their default values the update button works just fine.
here's my aspx page code
<asp:Button ID="Button1" CssClass="hide" runat="server" Text="Button" />
<ajaxToolkit:ModalPopupExtender runat="server" ID="cfPopUp" PopupControlID="Panel4"
TargetControlID="Button1" OkControlID="cfUpdateBtn" CancelControlID="cfCancelBtn" />
<asp:Panel ID="Panel4" runat="server" CssClass="modalPopup">
<asp:UpdatePanel ID="UpdatePanel2" runat="Server">
<ContentTemplate>
<asp:Panel ID="Panel13" CssClass="" runat="server">
<asp:Panel ID="Panel14" CssClass="" runat="server">
<div style="padding: 10px; border: 3px solid black; background-color: White; color: Black;">
<asp:Label ID="Label25" Width="200px" runat="server" Text="Health and Safety Net" /><div
class="seperator">
</div>
<table class="style143">
<tr>
<td class="style185">
<asp:Label ID="cfCategorylbl" runat="server" Text="Category:"></asp:Label>:
</td>
<td>
<asp:DropDownList ID="cbFactors_Categories" runat="server" Width="350px" Font-Names="Tahoma"
Font-Size="Small" ForeColor="DimGray" Height="24px" CssClass="style75">
</asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server" TargetControlID="cbFactors_Categories"
Category="categories" ServiceMethod="getCategory" ServicePath="~/2012/IrSubmitWebService.asmx"
PromptText="Select Category" />
</td>
<td align="center" rowspan="3" valign="top">
<asp:Label ID="lblFactor_ID" runat="server" Font-Names="Tahoma" Font-Size="Small"
ForeColor="DimGray" Style="font-style: italic" TabIndex="56"></asp:Label>
<cc1:DynamicPopulateExtender ID="lblFactor_ID_DynamicPopulateExtender" runat="server"
Enabled="True" TargetControlID="lblFactor_ID" BehaviorID="dp1" ServiceMethod="getFactorID"
ServicePath="~/2012/IrSubmitWebService.asmx">
</cc1:DynamicPopulateExtender>
<hr class="style157" />
<asp:Label ID="cfID" runat="server" Font-Names="Tahoma" Font-Size="Small" ForeColor="DimGray"
Style="font-style: italic" Width="400px" TabIndex="57"></asp:Label>
</td>
</tr>
<tr>
<td class="style185">
<asp:Label ID="cfTypeslbl" runat="server" Text="Type:"></asp:Label>
</td>
<td>
<asp:DropDownList ID="cbFactors_Types" runat="server" ForeColor="DimGray" Height="24px"
TabIndex="54" Width="350px" Font-Names="Tahoma" Font-Size="Small" CssClass="style75">
</asp:DropDownList>
<cc1:CascadingDropDown ID="cbFactors_Types_CascadingDropDown" runat="server"
TargetControlID="cbFactors_Types" ParentControlID="cbFactors_Categories" Category="type"
ServiceMethod="getTypeofAction" ServicePath="~/2012/IrSubmitWebService.asmx"
PromptText="Select Type">
</cc1:CascadingDropDown>
</td>
</tr>
<tr>
<td class="style185">
<asp:Label ID="cfFactorslbl" runat="server" Text="Factor:"></asp:Label>
</td>
<td>
<asp:DropDownList ID="cbFactors_Factors" runat="server" ForeColor="DimGray" Height="24px"
TabIndex="55" Width="350px" Font-Names="tahoma" Font-Size="Small" CssClass="style75">
</asp:DropDownList>
<cc1:CascadingDropDown ID="cbFactors_Factors_CascadingDropDown" runat="server"
TargetControlID="cbFactors_Factors" ParentControlID="cbFactors_Types" Category="category"
ServiceMethod="getFactor" ServicePath="~/2012/IrSubmitWebService.asmx" PromptText="Select Factor">
</cc1:CascadingDropDown>
</td>
</tr>
<tr>
<td class="style185">
<asp:Label Text="Justification:" ID="cfJustificationlbl" runat="server"></asp:Label>
</td>
<td colspan="2">
<asp:TextBox ID="txtJustification" runat="server" ForeColor="DimGray" Height="29px"
Style="font-family: Tahoma; font-size: small" TabIndex="56" TextMode="MultiLine"
ToolTip="Provide a justification for this factor." Width="775px" Font-Names="Tahoma"
Font-Size="Small"></asp:TextBox>
</td>
</tr>
</table>
<br />
<div style="text-align: center">
<asp:Button CausesValidation="false" ID="cfUpdateBtn" runat="server"
Text="Update" CssClass="button" /><span style="margin-left: 10px"><asp:Button CausesValidation="false"
ID="cfCancelBtn" runat="server" Text="Cancel" CssClass="button" /></span></div>
</div>
</asp:Panel>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
and my code behind for my update (it just closes the popup)
Protected Sub cfUpdateBtn_Click(sender As Object, e As EventArgs) Handles cfUpdateBtn.Click
cfPopUp.Hide()
End Sub
For the life of me I can't figure out why the update button wont work when the dropdowns are not the default value.
Thanks for your help guys
The possible reason may be you are binding your dropdownlist with a webservice. Whenever you click to an item on dropdownlist webservice may be called. If webservice is called then may be your page again loaded ? I don't know the exact reason why it is not working. You have to check the service behavior what happened when the service is called.
I basically rebuilt my modal popup and update panel like so
<asp:Panel ID="pnlEditPopup" runat="server" CssClass="modalPopup">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Panel ID="pnlEditPopupContent" runat="server">
<div style="padding: 10px; border: 3px solid black; background-color: White; color: Black;">
<table cellpadding="0" cellspacing="4" border="0">
<tr>
<td class="name">Category:</td>
<td class="value">
<asp:DropDownList id="ddCat" runat="server">
<asp:listitem value="">No Selection</asp:listitem>
<asp:listitem value="Action">Action</asp:listitem>
<asp:listitem value="Worksite">Worksite</asp:listitem>
<asp:listitem value="Human Factors">Human Factors</asp:listitem>
<asp:listitem value="System Factors">System Factors</asp:listitem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="name">Type:</td>
<td class="value">
<asp:DropDownList id="ddType" runat="server" />
<ajaxToolkit:CascadingDropDown ID="ccType" runat="server"
TargetControlID="ddType"
ParentControlID="ddCat"
PromptText="No Selection"
LoadingText="Please Wait..."
ServicePath="~/2012/IrSubmitWebService.asmx"
ServiceMethod="getTypeofAction"
Category="Other"
/>
</td>
</tr>
<tr>
<td class="name">Factor:</td>
<td class="value">
<asp:DropDownList id="ddfactor" runat="server" />
<ajaxToolkit:CascadingDropDown ID="ccFactor" runat="server"
TargetControlID="ddfactor"
ParentControlID="ddType"
PromptText="No Selection"
LoadingText="Please Wait..."
ServicePath="~/2012/IrSubmitWebService.asmx"
ServiceMethod="getFactor"
Category="Other"
/>
</td>
</tr>
<tr>
<td>
Justification:
<asp:Label ID="factorID" runat="server" Visible="false"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtJustification" runat="server" ForeColor="DimGray" Height="100px"
Style="font-family: Tahoma; font-size: small" TabIndex="56" TextMode="MultiLine"
ToolTip="Provide a justification for this factor." Width="300px" Font-Names="Tahoma"
Font-Size="Small"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Factor ID<br />
and Description:
</td>
<td>
<asp:Label ID="factor_id_Desc" runat="server" Width="300px" Font-Names="Tahoma" Font-Size="Small"
ForeColor="DimGray" TabIndex="56"></asp:Label>
<cc1:DynamicPopulateExtender ID="DynamicPopulateExtender1" runat="server"
Enabled="True" TargetControlID="factor_id_Desc" BehaviorID="dp1" ServiceMethod="getFactorID"
ServicePath="~/2012/IrSubmitWebService.asmx">
</cc1:DynamicPopulateExtender>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="btnOkEditPopup" runat="server" Text="Ok" CssClass="button"/>
<span style="margin-left:10px"><asp:button id="btnCancelEditPopup" runat="server" text="Cancel" CssClass="button"/></span>
</td>
</tr>
</table>
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="mpeEdit" runat="server"
TargetControlID="btnOpenEditPopup"
PopupControlID="pnlEditPopup"
/>
Fixed my issue. I still dont know why it wasn't working when I asked the question but I was able to solve it. Thanks to all who looked into it for me.

Resources