obout:ColorPickerExtender in UpdatePanel causes full postback - asp.net

I have an obout ColorPickerExtender in an UpdatePanel along with some other controls. The other controls execute partial postbacks as expected, but the ColorPickerExtender executes a full postback despite being in the UpdatePanel. Here's the relevant ASPX:
<asp:Content ContentPlaceHolderID="cphMainDivContentPlaceHolder" runat="server">
<asp:UpdatePanel ID="upGeneralLayoutData" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtLayoutName" runat="server"
ToolTip="Enter a name for this layout (recommend you use a unique name)"
OnTextChanged="txtLayoutName_TextChanged"
AutoPostBack="true"
MaxLength="255" />
<obout:ColorPickerExtender ID="cpeLayoutBackgroundColor" runat="server"
OnClientOpen="onColorPickerExtenderOpen"
AutoPostBack="true"
TargetProperty="style.backgroundColor"
OnColorPostBack="cpeLayoutBackgroundColor_ColorPostBack"
PopupButtonID="txtLayoutBackgroundColor"
TargetControlID="txtLayoutBackgroundColor"
HexView="False"
PickButton="False" />
<asp:TextBox ID="txtLayoutBackgroundColor" runat="server"
ToolTip="Select the background color for this layout"
CssClass="ColorPickerExtenderTextBox"
style="cursor: pointer"
Width="50"
ReadOnly="True" />
<br />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
As I was formulating the question, I was able to figure out the answer (see below)--instead of trashing the question, I left it here for others to use.

It turns out that the ColorPickerExtender is not being registered as an async postback control. I got the clue from this post. I'm not sure why it doesn't register as an async control when the others do, but the fix is easy enough--add a <Triggers> section that explicitly designates it as async, like so:
<Triggers>
<asp:AsyncPostBackTrigger ControlID="cpeLayoutBackgroundColor" EventName="ColorPostBack" />
</Triggers>

Related

FileUpload.Hasfile is returning false(What is the reason?)

I have a fileupload control on my .aspx page.
<asp:FileUpload ID="FileUpload1" runat="server" />
I am validating my control on my CS page.
if (FileUpload1.HasFile)
but this if condition is returning always false. I am not getting what is the actual reason! Can anyone help me in this?
FileUpload control is not compatible with UpdatePanel. You have two options
Move the control outside of UpdatePanel
If not possible, add a PostBackTrigger on the UpdatePanel
An example
<Triggers>
<asp:PostBackTrigger ControlID="yourButtonIdThatSubmitsFile" />
</Triggers>
For more information, you can refer to http://forums.asp.net/t/1142794.aspx
I have put my FileUpload Control into a Updatepanel. Then apply a trigger on those buttons from where data is submitting.
<td>
<asp:UpdatePanel runat="server" ID="updatepanel1">
<Triggers><asp:PostBackTrigger ControlID="btnsubNxtClm" /></Triggers>
<Triggers><asp:PostBackTrigger ControlID="btnsubmit" /></Triggers>
<ContentTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</td>

UpdatePanel does not have a public property named 'TextBox'.

I'm looking to update the contents of a panel using an asp:updatepanel.
I get an error on the page saying: DotNetNuke.Services.Exceptions.ModuleLoadException: Type 'System.Web.UI.UpdatePanel' does not have a public property named 'TextBox'.
See code below:
<asp:ScriptManager runat="server" ID="ScriptManager" />
<asp:UpdatePanel runat="server" ID="brandAddingContainer" Visible="false">
<ContentTemplate>
<asp:LinkButton runat="server" ID="brandAddingPrompt">
<img src="/images/add.gif" alt="Add New Brand" onclick="addNewBrand_clicked"/> Add New Brand
</asp:LinkButton>
<asp:Panel ID="sendNewBrand" runat="server">
<asp:TextBox runat="server" ID="newBrandName"></asp:TextBox>
<asp:Button runat="server" ID="sendBrandName" Text="Add Brand" OnClick="sendNewBrand_clicked" />
<asp:Label runat="server" ID="insertionFeedback" Visible="false" />
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="brandAddingPrompt" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
Using ScriptManager in module controls is not advisable, I would suggest to remove ScriptManager from your module code and use Enable Prtial Rendering checkbox in module control definition.
What version of .net framework and dnn are you using? try installing ajax extensions installed?
there is also a an entire section in adef web server site here that can be helpful.

<asp:FileUpload with UpdatePanel

Im trying tp upload more than one image, and when each one I upload I will show it in a repeater, but in the code behind the FileUpload1.HasFile is always False , this is a piece of my code :
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional" >
<ContentTemplate>
<asp:Repeater ID="rpUploadedImages" runat="server">
<ItemTemplate>
<img src='../Images/<%# DataBinder.Eval(Container.DataItem, "ImagePath")%>'/><br />
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnupload" EventName="click" />
</Triggers>
</asp:UpdatePanel>
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<asp:Button ID="btnupload" runat="server" Text="Upload" onclick="btnupload_Click" />
The FileUpload control does not work with UpdatePanel, you will need to do a full post back to get the file on the server... Now there are a lot of tricks to make it ajaxy...
http://geekswithblogs.net/ranganh/archive/2008/04/01/file-upload-in-updatepanel-asp.net-ajax.aspx
Another tricky way is to create iframe with fileupload + submit button(or some trigger) inside your main form. iframe will postback with no effect to main page.

Creating Multiple Hidden Div's in ASP.Net |Ajax | JQuery

i'm kinda new in web programming,
i'm trying to design a search page.
i want to creating few radio buttons where each click on a radio button will show a div
contains the related search div's.
and from there to do the query to the database(not related to the post)
how can i do that ?
tried to search for it , and didn't get good answer.
i want that the change of the page will be in server side and not the client side.
p.s.
i have been working with ajax control kit so far..
thanks for the help.
You just need an UpdatePanel, radio buttons and a MultiView control.
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
<asp:RadioButton ...
<asp:RadioButton ...
</div>
<asp:MultiView ID="mvAll" runat="server" ActiveViewIndex="-1">
<asp:View ID="vwFirst" runat="server">
</asp:View>
<asp:View ID="vwSecond" runat="server">
</asp:View>
...
</asp:MultiView>
</ContentTemplate>
</asp:UpdatePanel>
When the selected radio button changed you just set the View related to be active,
mvAll.SetActiveView(ViewIDYouNeed);
You can accomplish this with Panels and an Update Panel.
<asp:RadioButton ID="rdo1" AutoPostBack="true" GroupName="radios" runat="server" OnCheckedChanged="ShowDivs" />
<asp:RadioButton ID="rdo2" AutoPostBack="true" GroupName="radio2" runat="server" OnCheckedChanged="ShowDivs" />
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnl1" runat="server" Visible="false"></asp:Panel>
<asp:Panel ID="pnl2" runat="server" Visible="false"></asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rdo1" />
<asp:AsyncPostBackTrigger ControlID="rdo2" />
</Triggers>
</asp:UpdatePanel>
You would then handle setting the Visible property of the panels in your ShowDivs method in your code behind.
Or, you could use jquery/javascript to accomplish this.
<input type="radio" onClick="ShowDiv(1)" />
function ShowDiv(id) {
HideDivs();
$(id).show('slow');
}

Refresh User Control without Refreshing the Page

I have a page and it has a button and a user control.
I want to refresh the user control without refreshing the page.
I know I cannot do it otherwise so what I did is wrapped my user control inside the Update Panel.
<asp:TextBox ID="txtName" runat="server"></asp:TextBox><br />
<asp:Button ID="btnAdd" runat="server" Text="Add name to list" OnClick="btnAdd_Click" /><br /><br />
<asp:UpdatePanel ID="upShowNames" runat="server">
<ContentTemplate>
<uc1:ShowNames ID="ucShowNames" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnAdd" />
</Triggers>
</asp:UpdatePanel>
But I still the control won't refresh.
I also tried calling the update panels. The Update() method by changing its UpdateMode to Conditional but that does not work either...
Does anyone know how can I do it?
Please change these 2 things
<asp:UpdatePanel ID="upShowNames" runat="server" UpdateMode="Conditional">
<asp:AsyncPostBackTrigger ControlID="btnAdd" EventName="Click"/>
You missed the EventName on the postback trigger, once you add that, it should work :-)

Resources