I have placed fileupload and asp button in update panel and update progress bar, now my problem is i am unable to get update progressbar on button click , my code is
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:UpdatePanel ID="up1" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="btnSubmit" />
</Triggers>
<ContentTemplate>
<div class="bodytext" style="height: 480px; width: 830px;">
<table style="width: 600px" align="center">
<tr>
<td class="style2">
<br />
File Attachment
</td>
<td>
<br />
<asp:FileUpload ID="fluattach" runat="server" ClientIDMode="Static" />
</td>
<td>
</td>
</tr>
<tr>
<td class="style2">
</td>
<td>
</td>
<td>
<span class="art-button-wrapper"><span class="l"></span><span class="r"></span>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" CssClass="art-button" ClientIDMode="Static"
OnClick="btnSubmit_Click" />
</span>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="up1"
DynamicLayout="true">
<ProgressTemplate>
<div id="progressBackgroundFilter">
</div>
<div id="Progressbar" class="Progressbar" align="center" valign="middle" runat="server">
<asp:Image ID="Image1" Width="75" Height="95" runat="server" ImageUrl="~/images/animation_processing.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
i wrote that code it is working fine but unable to see the progressbar in saving time and send the mail, i can remove the trigger progressbar is wroking in save time but sending mail (fileupload HAS returns the false) so no attachment added, i have working both functionalaties, how it possible
please help me as quick as possible....
thank u
hmk
It seems you messed up your code. Try to keep it simple and then try again:
<asp:UpdateProgress runat="server" id="PageUpdateProgress1" AssociatedUpdatePanelID="UpdatePanel1" DynamicLayout="false">
<ProgressTemplate>
Processing Request from Update 1. Please Wait..
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel runat="server" id="UpdatePanel1">
<ContentTemplate>
<asp:Button runat="server" id="UpdateButton" onclick="UpdateButton_Click" text="Update 1" />
</ContentTemplate>
</asp:UpdatePanel>
protected void UpdateButton_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
}
Related
I have a problem with the update panel. I have made this table, and in that table i have two labels ("lblResult" and "lblCheat") which i need to be updated every time the button "btnCheck" or "ImageButton1" are clicked.
When I click the next button, the whole table is updated, and it works just fine with the code i have.
I don't understand why aren't the labels updating since I am using the update panel the same way with the "btnNext" button and with the "btnCheck" and "ImageButton1"
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<center>
<asp:Label ID="lblSound" runat="server" Visible="False"></asp:Label>
<table>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Sentence: "></asp:Label></td>
<td colspan="2">
<center>
<asp:Label ID="lblSentence" runat="server" Text=""></asp:Label>
</center>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Audio: "></asp:Label>
</td>
<td colspan="2">
<audio controls="">
<source src="Sound/<%=FilePath %>" />
</audio>
</td>
</tr>
<tr>
<td style="height: 11px">
<asp:Label ID="Label1" runat="server" Text="Write the correct word: "></asp:Label>
</td>
<td style="height: 11px">
<asp:TextBox ID="txtWord" runat="server" ontextchanged="txtWord_TextChanged"></asp:TextBox>
</td>
<td style="height: 11px">
<center>
<asp:Button ID="btnCheck" runat="server" onclick="btnCheck_Click"
Text="Check" />
<asp:ImageButton ID="ImageButton1" runat="server" Height="30px"
ImageUrl="~/Besilka/Question-mark-icon.png" onclick="ImageButton1_Click"
Width="30px" />
</center>
</td>
</tr>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<tr>
<td>
<center>
<asp:Label ID="lblResult" runat="server"></asp:Label>
</center>
</td>
<td>
<center>
<asp:Label ID="lblCheat" runat="server" Text=""></asp:Label>
</center>
</td>
</tr>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnCheck" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="ImageButton1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</table>
</center>
<asp:Button ID="btnNext" runat="server" onclick="btnNext_Click" Text="Next" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnNext" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
Thanks in advance!
Try setting your nested update panel UpdateMode="Conditional".
See this arcticle:
Specifically read "How UpdatePanel Controls Are Refreshed", it actually talks about UpdateMode and nesting update panels.
http://msdn.microsoft.com/en-us/library/bb386454%28v=vs.100%29.aspx
Update panels take a bit getting use to :)
If I write dummy text in the 2 labels before the update timer starts, one appears at the right and the other appears at the left as expected
However, when the updateTimer gets into picture both texts appear on the left stuck to each other
here's the code
<table width="100%" border="0" cellspacing="7" cellpadding="0">
<tr>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Timer runat="server" ID="UpdateTimer" Interval="5000" OnTick="UpdateTimer_Tick" />
<asp:UpdatePanel runat="server" ID="TimedPanel" UpdateMode="Conditional" RenderMode="Inline">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UpdateTimer" EventName="Tick" />
</Triggers>
<ContentTemplate>
<td align="left">
<asp:Label ID="userNameLabel" runat="server"></asp:Label>
</td>
<td align="right">
<asp:LinkButton ID="userWebsiteLabel" runat="server"></asp:LinkButton>
</td>
</ContentTemplate>
</asp:UpdatePanel>
</tr>
</table>
The TimedPanel is rendering as a span, like this:
<span id="TimedPanel">
<span id="userNameLabel">label</span>
<a id="userWebsiteLabel" href="javascript:__doPostBack('userWebsiteLabel','')">linkbutton</a>
</span>
Change your ContentTemplate to:
<ContentTemplate>
<asp:Label ID="userNameLabel" runat="server" Text="label" />
<asp:LinkButton ID="userWebsiteLabel" runat="server" Text="linkbutton" />
</ContentTemplate>
And add some CSS to align the LinkButton to the right:
<style type="text/css">
#TimedPanel a {float: right;}
</style>
I have an Updatepanel inside hidden Div, but I am getting "Could not find UpdatePanel with ID 'ctl00_ContentPlaceHolder_ctl04_UpdatePanel1'. I am trying to show and hide this panel from code behind. Thanks for any help. Here is my code.
<div id="div1" runat="server" style="display:none">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table id="Table1">
<tr>
<td>
<telerik:RadComboBox ID="RadComboBox1" runat="server"
AutoPostBack="true" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
</telerik:RadComboBox>
</td>
<td valign="top">
<asp:Button ID="button1" runat="server" OnClick="button1_Click" Text="Test1"
/><br />
<asp:Button ID="button2" runat="server" OnClick="button2_Click" Text="Test2"
/>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</div>
you can only manipulate the the code inside the ContentTemplate from the updatepanel's postbacks, so the "div1"s display property can't be changed by the updatepanel's postbacks.
you could move the div inside the updatepanel and then it should work
I'd try this:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel runat="server" id="div1" runat="server" style="display:none">
<table id="Table1">
<tr>
<td>
<telerik:RadComboBox ID="RadComboBox1" runat="server"
AutoPostBack="true" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
</telerik:RadComboBox>
</td>
<td valign="top">
<asp:Button ID="button1" runat="server" OnClick="button1_Click" Text="Test1"
/><br />
<asp:Button ID="button2" runat="server" OnClick="button2_Click" Text="Test2"
/>
</td>
</tr>
</table>
<asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
Keep in mind the client id of div1 will no longer be div1 (unless your using .net 4 in which case you can specify that it is'div1') you can fix this a variety of ways but basically you just need to add a little bit of javascript to the page that associates the actual WebControl.ClientID with 'div1'.
I am using ajax model popup extender in my asp.net page. From my page , on click of Save button , i popup panel using model popup extender.
If i cause postback from model popup , my backend (asp.net) form controls are coming front (ie) in the panel.
Here is my code snippet,
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="up_Save" runat="server">
<ContentTemplate>
<div>
<table border="0" cellpadding="2" cellspacing="2" width="100%">
<tr>
<td align="center" colspan="4">
<asp:Button ID="btn_Save" runat="server" Text="Save" Width="15%" OnClick="btn_Save_Click" />
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<cc1:ModalPopupExtender ID="BarrierRelayPopup" runat="server" PopupControlID="PopUp_Panel" TargetControlID="hiddenfield" CancelControlID="btn_Cancel_PopUp">
</cc1:ModalPopupExtender>
<asp:HiddenField ID="hiddenfield" runat="server" />
<asp:Panel runat="server" ID="PopUp_Panel" Width="50%" Height="30%" BackColor="Gainsboro" BorderStyle="Groove" >
<asp:UpdatePanel runat="server" ID="PopUp">
<ContentTemplate>
<table>
<tr>
<td align="left">
<asp:Label ID="lbl_Heading" runat="server" Text="Select Relay and Barrier :"></asp:Label>
</td>
</tr>
<tr>
<td>
<B_R:Barrier_Relay ID="Barrier_Relay" runat="server"/>
</td>
</tr>
<tr>
<td align="center">
<asp:Button ID="btn_OK" runat="server" Width="60px" Text="OK" OnClick="btn_OK_Click" /> <asp:Button ID="btn_Cancel_PopUp" runat="server" Width="60px" Text="Cancel" OnClick="btn_Cancel_PopUp_Click"/>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</form>
Can anybody help me in this.
If I understand you right I think what you want to do is wrap the controls inside the modal in an updatepanel. This will prevent the modal from closing if you need to do a postback from within the popup.
I'm using file upload in my site. I'm uploading word Document(Doc,Docx). Suddenly, it's not working. It is not getting the filename. It is showing empty!!! My Code is as follows:
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
<table width="100%" align="center">
<tr>
<td style="height: 21px" align="center">
<span class="lbl"></span>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Button ID="btnResumedload" Text="Download Resume" runat="server" BackColor="Maroon"
ForeColor="White" Font-Bold="true" OnClick="btnResumedload_Click" Height="27px"
Width="195px" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td align="center">
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<asp:Button ID="btnUploadnew" Text="Upload New" runat="server" BackColor="Maroon"
ForeColor="White" Font-Bold="true" OnClick="btnUploadnew_Click" Height="30px"
Width="198px" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td align="center">
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:Button ID="btnDel" Height="30px" Width="198px" OnClientClick="return confirm('Are you sure?');"
BackColor="Maroon" ForeColor="White" Font-Bold="true" Text="Delete Resume" runat="server"
OnClick="btnDel_Click"></asp:Button>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td align="center">
<asp:Label ID="lblmsg" runat="server" Font-Bold="True" ForeColor="Red" Visible="False"
Height="17px" Width="855px"></asp:Label>
</td>
</tr>
<tr>
<td align="center">
<span class="txt">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<%--<ajaxToolkit:AsyncFileUpload ID="fpResumenew" runat="server" Visible="false" />--%>
<asp:FileUpload ID="fpResumenew" runat="server" Visible="false" Width="226px" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnUpload" />
</Triggers>
</asp:UpdatePanel>
</span>
</td>
</tr>
<tr>
<td align="center">
</td>
</tr>
<tr>
<td style="vertical-align: top" align="center">
<%--<asp:Button ID="btnUpload" Font-Bold="true" DisabledText="Processing..." Visible="false"
Text="Upload" BackColor="Maroon" ForeColor="White" runat="server" OnClick="btnUpload_Click" />--%>
<cc1:ClickOnceButton ID="btnUpload" Font-Bold="true" DisabledText="Processing..."
Visible="false" Text="Upload" BackColor="Maroon" ForeColor="White" runat="server"
OnClick="btnUpload_Click" DisableAfterClick="True" />
</td>
</tr>
</table>
protected void btn_Click(object sender, EventArgs e)
{
string strfilename = fp.FileName.ToString();
if (fp.PostedFile.FileName.Trim().Length != 0)
{
binary = new byte[fp.PostedFile.ContentLength];
binary = fp.FileBytes;
doc = fp.FileName;
contenttype = fp.PostedFile.ContentType;
}
}
Just a sample!!!
Nothing works for me.. Problem is that I'm using three more buttons in the same page. The other buttons initializing the file upload control. So, when clicking the upload button, the file name is empty. So, I used another page for uploading the word document. Now, it is working.. !! Anyhow, I need the solution for this!! Anyone give me idea!!
Hai vaishu
FileUpload controls are not compatible with UpdatePanel when they are used to upload files as part of an asynchronous postback.
Just check the AJAX documentation. The FileUpload control is not supported inside an UpdatePanel (http://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx):
or
use asp:postbacktrigger instead of asyncpostbacktrigger
<asp:updatepanel runat="server" id="UpdatePanel1">
<contenttemplate>
<asp:FileUpload runat="server" id="FileUpload1" />
<asp:button runat="server" id="ButtonSubmit" text="Postback" />
</contenttemplate>
<triggers>
<asp:postbacktrigger controlid="ButtonSubmit" />
</triggers>
</asp:updatepanel>
or
use ajax for asynchronous file upload:
http://www.asp.net/(S(fu2l2uzphr2u3u45q2dnez55))/ajax/AjaxControlToolkit/Samples/AsyncFileUpload/AsyncFileUpload.aspx
The reason that the postback trigger is not working in your case is because the FileUpload Control is set to visible=false. If you use display:none instead, the postback trigger will work.
This works just fine, I finally solved the issue... the ButtonSubmit is reload by the trigger so the page got the info from the control.
<asp:updatepanel runat="server" id="UpdatePanel1">
<contenttemplate>
<asp:FileUpload runat="server" id="FileUpload1" />
<asp:button runat="server" id="ButtonSubmit" text="Postback" />
</contenttemplate>
<triggers>
<asp:postbacktrigger controlid="ButtonSubmit" />
</triggers>
</asp:updatepanel>