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

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');
}

Related

obout:ColorPickerExtender in UpdatePanel causes full postback

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>

Checkboxlist inside UpdatePanel triggers full postback when an item is checked

So I have this Checkboxlist and I want to implement a Select All feature for the elements inside it. I placed it inside an UpdatePanel, but everytime I click an item, the entire page is reloaded. This is my code:
<asp:UpdatePanel ID="CBLPanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<div class="LeftAligned">
<asp:Label ID="FilterLabel" runat="server" Text="Filter by:" />
<asp:DropDownList runat="server" ID="FilterDDL" AutoPostBack="true" OnSelectedIndexChanged="FilterDDL_SelectedIndexChanged" />
<asp:ImageButton ID="FB" runat="server" ImageUrl="~/images/filter.png" AlternateText="VALUE"
CssClass="filter_button" OnClick="FB_Click" />
<div onmouseout="javascript:bMouseOver=false;" onmouseover="javascript:bMouseOver=true;"
class="filter_div">
<asp:CheckBoxList AutoPostBack="true" ID="FilterCheckBoxList" ClientIDMode="Static"
runat="server" CssClass="filter_checklist collapsed" OnSelectedIndexChanged="FilterCheckBoxList_Selected">
</asp:CheckBoxList>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
I though I should set ChildrenAsTriggers to false and this way I would update only from the code, but it doesn't seem to work.
This looks like a familiar .NET Bug. Setting ClientIDMode=Auto on the CheckBoxList should fix it

ProgressBar show in GridView in asp.net

In Gridview cell, I have to show ProgressBar in ASP.NET.
I am using async event in ASP.NET 4.0
Could you guide me to find the solution for it?
I assume you mean from the client side ajax. If not, can you elaborate? If you are using a simple update panel you can just drop a Update Progress control on the page and put whatever you want to display as "progress" in the ProgressTemplate.
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdateProgress runat="server" id="PageUpdateProgress">
<ProgressTemplate>
Loading...
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel runat="server" id="Panel">
<ContentTemplate>
<asp:Button runat="server" id="UpdateButton" onclick="UpdateButton_Click" text="Update" />
</ContentTemplate>
</asp:UpdatePanel>
</form>

<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.

Update panel can not find the button which trigger it

I have a button is inside a another table(s) inside the update panel.
<Update panel>
<ContentTemplate>
<table>
<table>
<Button>
<table>
<table>
</ContentTemplate>
</Update panel>
I would like to add a button to Update panel's trigger.
But am getting an err says "Update panel can not find the button which trigger it".
I am getting "Sys.Webforms.PageRequestmanagerParseErrorException: This message recieved from manager could not be parsed. Common cause for this error are when response is modified by response.write"
Please help!
PostBackTrigger example:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btn1" runat="server" Text="Button 1-Partial Postback" />
<asp:Button ID="btn2" runat="server" Text="Button 2-Full Postback" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btn2" />
</Triggers>
</asp:UpdatePanel>

Resources