I have a button that appears after a method in c# is completed:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="submit" runat="server" Text="Submit" OnClick="submit_Click1" visible="true"/>
<button runat="server" class="submit2" id="closeWidget" visible="false">Close</button>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="submit" EventName="Click"/>
</Triggers>
$('.submit2').click(function () {
$('.widly').removeClass('window');
})
The problem is that when my method makes '.submit2' visible, my jQuery script doesn't recognize when i click on it.. However if i make it visible=true before the method is run, it works perfectly well.
So my question is, how do i make this work, after i change the visibility to true?
When using
visible="false"
the control is removed from the HTML output. If you just want to hide it, you can use the display style instead:
<button runat="server" class="submit2" id="closeWidget" style='display: none;'>Close</button>
Then you can show it by removing the display style attribute.
Related
I created a updatePanel, is include some dropdownlist and a few button and I use AsyncPostBackTrigger for not update all page when the click button or select dropdownlist.
My page structure that an aspx page and also use user control page. I use updatePanel on UserControlPage.
Here is My code and I wish you help me:
<asp:UpdatePanel ID="UpdMonthly" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddlSenetIslemleriAlinanUrun1" AutoPostBack="true" OnSelectedIndexChanged="ddlSenetIslemleriAlinanUrun1_SelectedIndexChanged" runat="server"></asp:DropDownList>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<asp:Button ID="btnKaydet" style="margin:10px ;" Width="100" Height="50" runat="server" Text="Kaydet" OnClick="btnKaydet_Click"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlSenetIslemleriAlinanUrun1" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnKaydet" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
I have some knowledge on placeholder but when the click dropdown or button, page is postback and placeholder knowledge dissappear.
how to fix postback problem?
Thanks for your answers.
Here is the scenario,
I have one update panel in which I have radio button.
On check of radio button I want to enable Panel which is outside the update panel.
I have tried following 2 things:
Placing the panel in another update panel didn't work.
Using JavaScript on click of radio button didn't work.
placing the panel in another updatepanel and set update mode as conditional.
You need to do one more thing
On check of radio button event you need to call update method of newly added update panel
UpdatePanel1.Update();
I hope this code sample helps you.
<asp:UpdatePanel ID="udp1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:RadioButton ID="rb1" runat="server" AutoPostBack="true" OnCheckedChanged="Control_CheckedChanged"
Text="Text" GroupName="Group1" />
<asp:RadioButton ID="rb2" runat="server" AutoPostBack="true" OnCheckedChanged="Control_CheckedChanged"
Text="Text2" GroupName="Group1" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="udp2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnl1" runat="server" Visible="false">
<asp:Label ID="lblText" runat="server" Text="Text"/>
</asp:Panel>
</ContentTemplate>
<asp:AsyncPostBackTrigger ControlID="rb1" />
<asp:AsyncPostBackTrigger ControlID="rb2" />
</asp:UpdatePanel>
protected void Control_CheckedChanged(object source, EventArgs e)
{
pnl1.Visible=rb1.Checked;
}
Im using an Ajax update panel with a c# multiline textbox which updates on a timer, but it keeps scrolling to the top, Ive tried setting maintainginscrollpositiononpostback to true and also tried various javascripts. The broswer im using is IE.
This is my asp code with a c# textbox on the form.
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True" Height="390px" TextMode="MultiLine" Width="836px"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
Im quite new to the updatepanel so maybe something is wrong there,, Thanks\
Please read this article. I think it will help you
Maintain Scroll Position after Asynchronous Postback
I am having a asyncfileupload inside a update panel, I want to upload the file once when a file is selected , the same code works well outside the update panel but my design is in such a way that I can put this outside the update panel, how can I make this work
<asp:UpdatePanel ID="UP_DDL" runat="server" UpdateMode="Always" Visible="true"
RenderMode="Inline">
<ContentTemplate>
<asp:asyncfileupload id="AFU_Doc" runat="server"
uploadingbackcolor="Yellow" onuploadedcomplete="btnDocUpload_Click"
onclientuploadcomplete="sa" throbberid="spanUploading2" />
<span id="spanUploading2" runat="server">Uploading...</span>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="AFU_Doc" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:FileUpload onchange="clickTheButton();" ID="FileUpload1" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
Button 1 is outside the update panel and the javascript that gets run when a user adds a file in the upload box is this:
function clickTheButton() {
document.getElementById('<%= Button1.ClientID %>').click();
}
The problem is simple. FileUpload1.HasFile == false. I don't know why this is, but when I put it in the update panel it ceases to work.
I have seen some other threads on this. But none of them answer why this is happening, they just point to things you can download.
EDIT: Really my main reason for wanting to do this is so that I can get a ..Uploading File.. Tag to pop up while the client is uploading to the server and once it has completed, display it in a datalist. I just cant get the UpdateProgress to work.
Basically you just need to make your button do a full postback to send the file. Also make sure that you have this.Form.Enctype = "multipart/form-data"; set in your code, or you can put in that page. AsyncPostbacks don't work with files for security reasons as mentioned, without hacks. (I've never been able to get it to work).
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:FileUpload onchange="clickTheButton();" ID="FileUpload1" runat="server" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
For security purposes, browsers don't let you post files via javascript. Imagine if I could write a little bit a javascript to asynchronously submit the contents of your My Documents folder to my server.
So javascript-ish methods of posting the form, like the XMLHttpRequest used by the UpdatePanel, won't work.
This post describes a decent work around if you're on 3.5 SP1. http://geekswithblogs.net/ranganh/archive/2009/10/01/fileupload-in-updatepanel-asp.net-like-gmail.aspx
And this post describes a couple work arounds if you'd prefer not to use the AjaxControlToolkit. http://geekswithblogs.net/ranganh/archive/2008/04/01/file-upload-in-updatepanel-asp.net-ajax.aspx
File Upload will not work with a partial post back.
So just add this line at your page load
ScriptManager.GetCurrent(this).RegisterPostBackControl(this.YourControlID);
Or use PostBackTrigger.
<Triggers>
<asp:PostBackTrigger ControlID="YourControlID" />
</Triggers>
Or You need special AsyncFileUpload control as defined in AjaxControl Toolkit.
<ajaxToolkit:AsyncFileUpload OnClientUploadError="uploadError"
OnClientUploadComplete="uploadComplete" runat="server"
ID="AsyncFileUpload1" Width="400px" UploaderStyle="Modern"
UploadingBackColor="#CCFFFF" ThrobberID="myThrobber" />
You can check here.