Showing posts with label include. Show all posts
Showing posts with label include. Show all posts

Monday, March 26, 2012

Multiview control

Hi.

I used three radio button to switch among multiview control, how may I include AJAX into radio button control, so it doesn't post back when I try to change view ? I tried, it doesn't seem to work.

thanks for the help.

Hi,

You can avoid the postback by wrapping them in an UpdatePanel. For instance:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { MultiView1.ActiveViewIndex = RadioButtonList1.SelectedIndex; }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div>  <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> </asp:RadioButtonList> <asp:MultiView ID="MultiView1" runat="server"> <asp:View ID="View1" runat="server"> View1</asp:View> <asp:View ID="View2" runat="server"> View2</asp:View> <asp:View ID="View3" runat="server"> View3</asp:View> </asp:MultiView> </ContentTemplate> </asp:UpdatePanel> </form></body></html>
Hope this helps.

thanks.

But, I don't understand, in the radio button, it says AutoPostBack=true. I did exactl the way you did except put radio button in the updatepanel, what is the magic for this updatepanel ?

thanks so much for the help.


That's weird. Can you show me your page?


Hi. this is my code.

<divstyle="border-bottom:dotted; border: 1px;">

<asp:MultiViewid="MultiView1"runat="server"ActiveViewIndex="0">

<asp:ViewID="View1"runat="server">

<asp:LabelID="lblMsg"runat="server"Width="273px"Font-Bold="True"ForeColor="Red"></asp:Label><br/>

<asp:TextBoxID="txtAddress"runat="server"></asp:TextBox>

<asp:LabelID="Label2"runat="server"Text="Ex. 101 Monroe St"Width="111px"></asp:Label><br/>

<asp:TextBoxID="txtZip"runat="server"></asp:TextBox>

<asp:LabelID="Label3"runat="server"Text="Ex. 20850"Width="106px"></asp:Label><br/>

<asp:TextBoxID="txtMiles"runat="server">2</asp:TextBox>

<asp:LabelID="Label4"runat="server"Text="Within Miles"Width="107px"></asp:Label><br/>

<asp:ButtonID="btnAddress"runat="server"Text="Find"OnClick="btnAddress_Click"/>

</asp:View>

<asp:ViewID="View2"runat="server">

<asp:DropDownListID="lstCities"runat="server"></asp:DropDownList><br/>

<asp:ButtonID="btnCities"runat="server"Text="Find"OnClick="btnCities_Click"/>

</asp:View>

<asp:ViewID="View3"runat="server">

<asp:DropDownListID="lstZipCode"runat="server">

</asp:DropDownList>

<asp:ButtonID="btnZip"runat="server"Text="Find"OnClick="btnZip_Click"/>

</asp:View>

</asp:MultiView>

</div>


The code you posted isn't sufficient to reproduce the issue. Can you show me more?


<divstyle="border-bottom:dotted; border: 1px;">

<asp:RadioButtonID="RadioButton1"runat="server"Text="Address"GroupName="grpSelection"AutoPostBack="true"OnCheckedChanged="RadioButton1_CheckedChanged"Font-Bold="True"ForeColor="Blue"Width="80px"checked="true"/>

<asp:RadioButtonID="RadioButton2"runat="server"Text="Cities"GroupName="grpSelection"OnCheckedChanged="RadioButton2_CheckedChanged"AutoPostBack="True"Font-Bold="True"ForeColor="Blue"Width="67px"/>

<asp:RadioButtonID="RadioButton3"runat="server"Text="Zip Code"GroupName="grpSelection"OnCheckedChanged="RadioButton3_CheckedChanged"AutoPostBack="True"Font-Bold="True"ForeColor="Blue"Width="84px"/>

</div>

<scriptlanguage="c#"runat="server">

protectedvoid RadioButton1_CheckedChanged(object sender,EventArgs e)

{

MultiView1.SetActiveView(View1);

}

protectedvoid RadioButton2_CheckedChanged(object sender,EventArgs e)

{

MultiView1.SetActiveView(View2);

}

protectedvoid RadioButton3_CheckedChanged(object sender,EventArgs e)

{

MultiView1.SetActiveView(View3);

}

</script>

thanks.


Here is the page that I made with the codes your provided, it worked fine.

<%@. Page Language="C#" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void RadioButton1_CheckedChanged(object sender, EventArgs e) { MultiView1.SetActiveView(View1); } protected void RadioButton2_CheckedChanged(object sender, EventArgs e) { MultiView1.SetActiveView(View2); } protected void RadioButton3_CheckedChanged(object sender, EventArgs e) { MultiView1.SetActiveView(View3); } protected void btnAddress_Click(object sender, EventArgs e) { } protected void btnCities_Click(object sender, EventArgs e) { } protected void btnZip_Click(object sender, EventArgs e) { }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel runat="server" ID="up1"> <ContentTemplate> <div style="border-bottom:dotted; border: 1px;"><asp:MultiView id="MultiView1" runat="server" ActiveViewIndex="0"><asp:View ID="View1" runat="server"><asp:Label ID="lblMsg" runat="server" Width="273px" Font-Bold="True" ForeColor="Red"></asp:Label><br /><asp:TextBox ID="txtAddress" runat="server"></asp:TextBox><asp:Label ID="Label2" runat="server" Text="Ex. 101 Monroe St" Width="111px"></asp:Label><br /><asp:TextBox ID="txtZip" runat="server"></asp:TextBox><asp:Label ID="Label3" runat="server" Text="Ex. 20850" Width="106px"></asp:Label><br /><asp:TextBox ID="txtMiles" runat="server">2</asp:TextBox><asp:Label ID="Label4" runat="server" Text="Within Miles" Width="107px"></asp:Label><br /><asp:Button ID="btnAddress" runat="server" Text="Find" OnClick="btnAddress_Click" /></asp:View><asp:View ID="View2" runat="server"><asp:DropDownList ID="lstCities" runat="server"></asp:DropDownList><br /><asp:Button ID="btnCities" runat="server" Text="Find" OnClick="btnCities_Click" /></asp:View><asp:View ID="View3" runat="server"> <asp:DropDownList ID="lstZipCode" runat="server"></asp:DropDownList>     <asp:Button ID="btnZip" runat="server" Text="Find" OnClick="btnZip_Click" /></asp:View></asp:MultiView></div><div style="border-bottom:dotted; border: 1px;"> <asp:RadioButton ID="RadioButton1" runat="server" Text="Address" GroupName="grpSelection" AutoPostBack="true" OnCheckedChanged="RadioButton1_CheckedChanged" Font-Bold="True" ForeColor="Blue" Width="80px" checked="true" />    <asp:RadioButton ID="RadioButton2" runat="server" Text="Cities" GroupName="grpSelection" OnCheckedChanged="RadioButton2_CheckedChanged" AutoPostBack="True" Font-Bold="True" ForeColor="Blue" Width="67px" />      <asp:RadioButton ID="RadioButton3" runat="server" Text="Zip Code" GroupName="grpSelection" OnCheckedChanged="RadioButton3_CheckedChanged" AutoPostBack="True" Font-Bold="True" ForeColor="Blue" Width="84px" /></div> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

Another tip is you need to make sure ajax extension is successfully installed on your machine, andnecessary entries have been added into your web.config.


thanks. let me try it out !


Hi.

just tried it. I don't have the file for AjaxControlToolkit, where may I find the file ?

thanks.


Hi.

In order to use UpdatePanel, I have to install AjaxControltoolkit, right ?

thanks.


shukuo:

Hi.

just tried it. I don't have the file for AjaxControlToolkit, where may I find the file ?

thanks.

http://www.codeplex.com/AtlasControlToolkit/Release/ProjectReleases.aspx?ReleaseId=4923


shukuo:

Hi.

In order to use UpdatePanel, I have to install AjaxControltoolkit, right ?

thanks.

No, Ajax Extension is enough.

Wednesday, March 21, 2012

need help to start, Scriptmanager

Hello,

First time I try to include an atlas control.

I get an error "Extender controls require a ScriptManager to be present on the page."

Attempting to create cascading drop down lists, so here is the aspx code: (took cars sample and edited)

<atlasToolkit:CascadingDropDownID="CascadingDropDown1"

runat="server">

<atlasToolkit:CascadingDropDownProperties

TargetControlID="projectDDL"

Category="Project"

PromptText="Select a manufacturer"

ServiceMethod="populateProjectDDL"/>

<atlasToolkit:CascadingDropDownProperties

TargetControlID="wellDDL"

ParentControlID="projectDDL"

PromptText="Select a well"

ServiceMethod="populateWellDDL"

Category="Well"/>

<atlasToolkit:CascadingDropDownProperties

TargetControlID="sectionDDL"

ParentControlID="wellDDL"

PromptText="Select a section"

ServiceMethod="populateSectionDDL"

Category="Section"/>

</atlasToolkit:CascadingDropDown>

<asp:DropDownListID="projectDDL"runat="server"CssClass="label"Style="z-index: 105;

left: 281px; position: absolute; top: 92px"AutoPostBack="True"TabIndex="1">

</asp:DropDownList>

<asp:DropDownListID="wellDDL"runat="server"CssClass="label"Style="z-index: 106;

left: 281px; position: absolute; top: 154px"AutoPostBack="True"TabIndex="2">

</asp:DropDownList>

<asp:DropDownListID="sectionDDL"runat="server"CssClass="label"Style="z-index: 107;

left: 281px; position: absolute; top: 214px"TabIndex="3">

</asp:DropDownList>

In the code behind I have three populate subs that fetch data from sql db:

PrivateSub populateProjectDDL()

PrivateSub populateWellDDL()

PrivateSub populateSectionDDL()

Also had some*_SelectedIndexChanged subs, that used to do the job atlas is now going to do I suppose.

Back to the problem: scriptmanager?! What is that - where do I put it? Please help me get my first alas control going... Would be very nice..

A ScriptManager tag looks like:

<atlas:ScriptManager ID="ScriptManager1" runat="server" />

You may want toread more on Atlas itself to understand what one is and what it can do.


Yeah, sry, kinda rushed that question in,

didn't think this post would even be approved, delete, close, whatever... hehe

Thx for reply, sry about this post.