ASP.Net C# - Multiple UpdateProgress controls on a page - c#

I'm trying to implement UpdatePanels and UpdateProgress controls. I have two UpdatePanels that contain two different DropDownLists (ddlQuestion5IDs and ddlQuestion6IDs).
When I change the selected index of ddlQuestion6IDs, the UpdateProgress loads for both UpdatePanels/DropDownLists. Is this how they normally behave and is there a way of only displaying the corresponding UpdateProgress for each UpdatePanel?
<p>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label6" runat="server" Text="Question 5:" Font-Bold="true"></asp:Label>
<br />
<asp:DropDownList ID="ddlQuestion5IDs" runat="server" OnSelectedIndexChanged="ddlQuestion5IDs_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DynamicLayout="true">
<ProgressTemplate>
<img src="images/loader.gif" height="20" />
</ProgressTemplate>
</asp:UpdateProgress>
<br />
<asp:Label ID="Label19" runat="server" Text="Question type:" Font-Italic="true"></asp:Label>
<br />
<asp:Label ID="lblQuestion5Type" runat="server" Text=""></asp:Label>
<br /><br />
<asp:Label ID="Label22" runat="server" Text="Question:" Font-Italic="true"></asp:Label>
<br />
<asp:Label ID="lblQuestion5" runat="server" Text=""></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlQuestion5IDs" EventName="SelectedIndexChanged"/>
</Triggers>
</asp:UpdatePanel>
</p>
<p>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label7" runat="server" Text="Question 6:" Font-Bold="true"></asp:Label>
<br />
<asp:DropDownList ID="ddlQuestion6IDs" runat="server" OnSelectedIndexChanged="ddlQuestion6IDs_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
<asp:UpdateProgress ID="UpdateProgress2" runat="server" DynamicLayout="true">
<ProgressTemplate>
<img src="images/loader.gif" height="20" />
</ProgressTemplate>
</asp:UpdateProgress>
<br />
<asp:Label ID="Label21" runat="server" Text="Question type:" Font-Italic="true"></asp:Label>
<br />
<asp:Label ID="lblQuestion6Type" runat="server" Text=""></asp:Label>
<br /><br />
<asp:Label ID="Label24" runat="server" Text="Question:" Font-Italic="true"></asp:Label>
<br />
<asp:Label ID="lblQuestion6" runat="server" Text=""></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlQuestion6IDs" EventName="SelectedIndexChanged"/>
</Triggers>
</asp:UpdatePanel>
</p>

By adding a AssociatedUpdatePanelID="UpdatePanelID" property to UpdateProgress

Related

Update Panel Not working at all

This is my code:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="txtEmailUser" TextMode="SingleLine" placeholder="Enter Email" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ValidationGroup="Panel1" ErrorMessage="RequiredFieldValidator"
ControlToValidate="txtEmailUser" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="buttonBuy" />
</Triggers>
</asp:UpdatePanel>
</div>
<br />
<asp:Button runat="server" ValidationGroup="Panel1" OnClick="buttonBuy_Click" ID="buttonBuy" width: 200px;"Text="Buy" />
I've tried many ways but still not working.
How can I solve it?

Change text in TextBox outside of UpdatePanel

I have a gridview inside an UpdatePanel (the gridview is showing in a popup). On click of a select button in that grid, I am trying to set a textbox text in the page. But its not working; if I remove the update panel then it will work.
This is my code in aspx:
<div><asp:TextBox ID="txt" runat="server /></div>
<asp:UpdatePanel ID="updLendersearch" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnLenderSearch" EventName="Click" />
</Triggers>
<ContentTemplate>
<div id="divLender" runat="server" class="white_content" style="height: 450px;top: 20%;width: 57%;">
<asp:Label ID="lblBenificiary" runat="server" Text="Beneficiary/Lender :" Font-Names="Candara" ></asp:Label>
<asp:TextBox ID="txtBeneficiaryName" Style="border: 1px solid red" runat="server" Width="80px" CssClass="txtboxes" Font-Names="Candara" ></asp:TextBox>
<asp:RequiredFieldValidator ID="reqBeneficiaryName" runat="server" ErrorMessage="*" ForeColor="Red" ControlToValidate="txtBeneficiaryName" ValidationGroup="lender"></asp:RequiredFieldValidator>
<asp:Label ID="lblLenderState" runat="server" Text="State :" Font-Names="Candara" ></asp:Label>
<asp:DropDownList ID="ddlLenderState" runat="server" AutoPostBack="true" Style="border: 1px solid red"
AppendDataBoundItems="true" CssClass="drpdown" OnSelectedIndexChanged="ddlLenderState_SelectedIndexChanged">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="reqLenderState" runat="server" ErrorMessage="*" ForeColor="Red" ControlToValidate="ddlLenderState" ValidationGroup="lender"></asp:RequiredFieldValidator>
<asp:Label ID="lblLenderCity" runat="server" Text="City :" Font-Names="Candara" ></asp:Label>
<asp:DropDownList ID="ddlLenderCity" runat="server" Width="100px" AutoPostBack="true"
AppendDataBoundItems="true" CssClass="drpdown" OnSelectedIndexChanged="ddlLenderCity_SelectedIndexChanged">
</asp:DropDownList>
<asp:Label ID="lblBeneficiaryZip" runat="server" Text="Zip :" Font-Names="Candara" ></asp:Label>
<asp:DropDownList ID="ddlBeneficiaryZip" runat="server" AppendDataBoundItems="true" Width="100px"
AutoPostBack="true" CssClass="drpdown">
</asp:DropDownList>
<asp:Button ID="btnBenefeciary" ValidationGroup="lender" runat="server" Text="Search" Font-Names="Candara" CssClass="btnBenefeciary" OnClick="btnBenefeciary_Click"/>
<br><br><br><br>
<div>
<asp:GridView ID="grvLenderDetails" CssClass="GridViewStyle" ShowHeaderWhenEmpty="true" OnRowCommand="grvLenderDetails_RowCommand" runat="server" AutoGenerateColumns="false" AutoGenerateSelectButton="true">
<Columns>
.. .. ..
</Columns>
<EmptyDataTemplate>
No Records To Display
</EmptyDataTemplate>
</asp:GridView>
</div>
</div>
<div id="fadeLender" class="black_overlay" runat="server">
<asp:ImageButton ID="imgLenderClose" ImageUrl="../Images/closepnlbtn.png" runat="server"
align="right" Style="margin-right: 140px; margin-top: 78px; border: 0px" OnClick="imgLenderClose_Click" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
If the TextBox is in another UpdatePanel. Make its UpdateMode Conditional which allows you to call its Update method programmatically.
protected void ddlLenderState_SelectedIndexChanged(object sender, GridViewSelectEventArgs e)
{
TxtInfo.Text = "Hello, i'm coming from the GridView.";
UpdInfo.Update();
}
Another approach would be to add an AsyncPostBackTrigger to the outer UpdatePanel with ControlID=grvLenderDetails and EventName=SelectedIndexChanged.
If it's not in an UpdatePanel, then you need to change that. Here are examples:
<asp:UpdatePanel runat="server" ID="UpdInfo" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="TxtInfo" runat="server />
</ContentTemplate>
</asp:UpdatePanel>
Here is the trigger approach that does not require you to call Update() from codebehind manually:
<asp:UpdatePanel runat="server" ID="UpdInfo" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="TxtInfo" runat="server />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="grvLenderDetails" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
Otherwise you'll need to use some sort of JS tricks, e.g.:
ScriptManager.RegisterStartupScript(this, GetType(), "ChangeTextBoxText", "<script type='text/javascript'>$('#"+txt.ClientId+"').val('Hello, i'm from the GridView');</script>", false);

How to updatepanel with image

I want to use update panel with image.
When image select and show for preview then only update that part only.
<div class="field-block button-height">
<label for="file" class="label">
<b>Image</b> (*.jpg)
</label>
<table>
<tr>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<td>
<span class="input file">
<span class="file-text"></span>
<span class="button compact">Select file</span>
<asp:FileUpload ID="fuMovieLogo" runat="server" CssClass="file withClearFunctions />"
</span>
<br />
<small class="input-info">Max file size: 2MB</small>
<asp:Button ID="btnPreview" runat="server" Text="Preview" onclick="btnPreview_Click" />
<asp:Button ID="btnCancelprev" runat="server" Text="Cancel" onclick="btnCancelprev_Click"/>
</td>
<td style="padding-left:10px">
<asp:Image ID="imgTheatreLogo" runat="server" Width="130px" />
<br />
<asp:Label ID="lblupdatelogo" runat="server" CssClass="lbl" Visible="false" Text="FDMovieUntitled.jpg"></asp:Label>
</td>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnPreview" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnCancelprev" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</tr>
</table>
</div>
Please Help me.
So you just need to restructure your markup a little then. You need to place imgTheatreLogo inside the update panel. The triggers are actually handled by controls outside the update panel. See this documentation for reference on exactly how the UpdatePanel works.
<?xml version="1.0" encoding="utf-8"?>
<div class="field-block button-height">
<label for="file" class="label">
<b>Image</b> (*.jpg)
</label>
<table>
<tr>
<td>
<span class="input file">
<span class="file-text"></span>
<span class="button compact">Select file</span>
<asp:FileUpload ID="fuMovieLogo" runat="server" CssClass="file withClearFunctions />"
</span>
<br />
<small class="input-info">Max file size: 2MB</small>
<asp:Button ID="btnPreview" runat="server" Text="Preview" onclick="btnPreview_Click" />
<asp:Button ID="btnCancelprev" runat="server" Text="Cancel" onclick="btnCancelprev_Click"/>
</td>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<td style="padding-left:10px">
<asp:Image ID="imgTheatreLogo" runat="server" Width="130px" />
<br />
<asp:Label ID="lblupdatelogo" runat="server" CssClass="lbl" Visible="false" Text="FDMovieUntitled.jpg"></asp:Label>
</td>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnPreview" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnCancelprev" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</tr>
</table>
</div>

Ajaxtoolkit ConfirmButtonExtender cannot fire

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<ContentTemplate>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Button" PostBackUrl="~/testing2.aspx" />
<asp:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server"
targetControlID="Button1"
ConfirmText="Are you sure you want to click this button"
ConfirmOnFormSubmit="True" />
<asp:TextBox ID="TextBox1" runat="server" Height="25px"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
My ConfirmButtonExtender just not working. The website do not pop up a box for me. Do I miss somethings? My code is above.
I think you are missing OnClientCancel property. Check out the working example below.
Ensure your page is using proper master page. This is a working code.
asp:Content ContentPlaceHolderID="SampleContent" Runat="Server">
<script type='text/javascript'>
function cancelClick() {
var label = $get('ctl00_SampleContent_Label1');
label.innerHTML = 'You hit cancel in the Confirm dialog on ' + (new Date()).localeFormat("T") + '.';
}
</script>
<ajaxToolkit:ToolkitScriptManager runat="Server" EnablePartialRendering="true" ID="ScriptManager1" />
<div class="demoarea">
<div class="demoheading">ConfirmButton Demonstration</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:LinkButton ID="LinkButton" runat="server" OnClick="Button_Click">Click Me</asp:LinkButton>
<ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server"
TargetControlID="LinkButton"
ConfirmText="Are you sure you want to click the LinkButton?"
OnClientCancel="cancelClick" />
<br />
<br />
<asp:Button ID="Button" runat="server" Text="Click Me" OnClick="Button_Click" /><br />
<ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender2" runat="server"
TargetControlID="Button"
OnClientCancel="cancelClick"
DisplayModalPopupID="ModalPopupExtender1" />
<br />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="Button" PopupControlID="PNL" OkControlID="ButtonOk" CancelControlID="ButtonCancel" BackgroundCssClass="modalBackground" />
<asp:Panel ID="PNL" runat="server" style="display:none; width:200px; background-color:White; border-width:2px; border-color:Black; border-style:solid; padding:20px;">
Are you sure you want to click the Button?
<br /><br />
<div style="text-align:right;">
<asp:Button ID="ButtonOk" runat="server" Text="OK" />
<asp:Button ID="ButtonCancel" runat="server" Text="Cancel" />
</div>
</asp:Panel>
<asp:Label ID="Label1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>

using multiple update progress for one update panel

I have multiple update progress in my page in different places but they all have the id of one update Panel because i'm only using one update Panel my question is how can i let one update progress to display it's content when an update is done.
here is a sample of my code :
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Label ID="platformLabel" runat="server"
Text=" <%$Resources:Resource,SelectPlatform %>">
</asp:Label>
<asp:LinkButton ID="platformHyperLink" runat="server"
CssClass="platformElementHL"
CommandArgument='<%# Eval("PLATFORM_ID")%>'
OnClick="platformHyperLink_Click"
OnClientClick="ShowSearchButton();" />
<asp:Label ID="PlatformNameLabel" runat="server"
Text='<%# Eval("PLATFORM_NAME")%>' >
</asp:Label>
<telerik:RadButton ID="findDevice" runat="server"
Text="<%$Resources:Resource,Search %>"
OnClientClicked="HideTootltip"
OnClick="findDevice_Click"
style="display:none">
</telerik:RadButton>
<asp:UpdateProgress ID="updProgress1"
AssociatedUpdatePanelID="UpdatePanel" runat="server">
<ProgressTemplate>
<img src="App_Themes/WebPortalTheme/images/HomePage/icon-loading-
animated.gif" width="20" height="20" alt="Progress" />
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdateProgress ID="updProgress2"
AssociatedUpdatePanelID="UpdatePanel" runat="server">
<ProgressTemplate>
<img src="App_Themes/WebPortalTheme/images/HomePage/icon-loading-
animated.gif" width="20" height="20" alt="Progress" />
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
</asp:UpdatePanel>
When i click on the link button the updateProgress1 should be displayed and when i click on the radButton the updateprogress2 should be displayed any ideas ?
You have to use two updatepanels (one for the linkbutton and another for the radiobutton) and associate each updateprogress with the corresponding. If you need to update the entire page use one global updatepanel , by setting the childastrigger option as appropriate.
<asp:UpdatePanel ID="UpdtGlobal" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text=" <%$Resources:Resource,SelectPlatform %>" />
<asp:UpdatePanel ID="UpdtLinkButton" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CssClass="platformElementHL" CommandArgument='<%# Eval("PLATFORM_ID")%>'
OnClick="platformHyperLink_Click" OnClientClick="ShowSearchButton();" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("PLATFORM_NAME")%>' />
<asp:UpdatePanel ID="UpdtRadButton" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<telerik:radbutton id="findDevice" runat="server" text="<%$Resources:Resource,Search %>"
onclientclicked="HideTootltip" onclick="findDevice_Click" style="display: none" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID="UpdtLinkButton"
runat="server">
<ProgressTemplate>
<img src="App_Themes/WebPortalTheme/images/HomePage/icon-loading-animated.gif" width="20"
height="20" alt="Progress" />
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdateProgress ID="UpdateProgress2" AssociatedUpdatePanelID="UpdtRadButton"
runat="server">
<ProgressTemplate>
<img src="App_Themes/WebPortalTheme/images/HomePage/icon-loading-animated.gif" width="20"
height="20" alt="Progress" />
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
</asp:UpdatePanel>

Categories

Resources