Showing posts with label client. Show all posts
Showing posts with label client. Show all posts

Wednesday, March 28, 2012

Change visible accordion panel client side

How can I change which accordion panel is visible using javascript?

Try this ..

function OpenPane(paneIndex) {var accHost = $get(<AccordionID>).AccordionBehavior ;accHost.set_SelectedIndex( paneIndex );}The "AccordionBehavior" lets you access the methods as you would do with a BehaviorID.
Please mark my reply as an answer if this solves the issue

Thanks for the response. I added alerts to the javascript as shown below, because nothing was happening. The first alert works, but the second alert is never displayed.

function

OpenPane(paneIndex)

{

alert(paneIndex);

var accHost = $get('Accordion1').AccordionBehavior;

alert(accHost);

accHost.set_SelectedIndex( paneIndex );

}

What's wrong?


Hi,

If you dont get the second alert , you should have an error at the line $get('Accordion1').AccordionBehavior.

Can you check if $get('Accordion1') is a valid object .

change the code to be

functionOpenPane(paneIndex)

{

alert(paneIndex);

var accord = $get('Accordion1');

var accHost ;

if( accord != null)

{

accHost = accord.AccordionBehavior;

}

alert( accord );

alert(accHost);

accHost.set_SelectedIndex( paneIndex );

}

and also , what is the ID of the Accordion You are using , "Accordion1" ?


That code should work. If you're not getting to the second alert(), my guess is that "$get('Accordion1')" is returning null. Are you sure you have the correct ID of your Accordion?

If "Accordion1" is the server ID, you probably want: $get('<%= Accordion1.ClientID %>') in case the client ID is different (because it's inside a naming container, for example).


Excellent. Between Phanatic and Steve it is now working properly. Thanks very much, both of you.

Hi,
Need your help.
I am using the Accordion Panel. I have tried your code, but unfortunately couldnt get it to work.

I am getting error in accessing the property AccordionBehavior.

"accHost = accord.AccordionBehavior;"
accHostalways contain undefined value.

any help would be apprecitated..

Thanks in advance.

--Saurabh

.

Change Object name in generated WSDL

Good day,

I have a Web Method that uses a simple custom object, name Client, as a parameter, and also returns a Client.

However, in the generated WSDL, I want "element name="Client" " to be changed to "element name="THE_CLIENT", but without changing the class name.

Is there a way to specify that an object should have another name in the wsdl, Something like [WebMethod(Description="DESCRIPTION")], but for a class?

Thank you, have a nice day!

Hi,

I think this link provide all information you need:http://msdn2.microsoft.com/en-us/library/2baksw0z.aspx

By default, an XML element name is determined by the class or member name. In a simple class named Book, a field named ISBN will produce an XML element tag <ISBN>, as shown in the following example.

Visual Basic

Copy Code

PublicClass BookPublic ISBNAsStringEndClass' When an instance of the Book class is serialized, it might' produce this XML:' <ISBN>1234567890</ISBN>.

C#

Copy Code

publicclass Book{publicstring ISBN;}// When an instance of the Book class is serialized, it might// produce this XML:// <ISBN>1234567890</ISBN>.

This default behavior can be changed if you want to give the element a new name. The following code shows how an attribute enables this by setting theElementName property of aXmlElementAttribute.

Visual Basic

Copy Code

PublicClass TaxRates < XmlElement(ElementName ="TaxRate")> _Public ReturnTaxRateAsDecimalEndClass

C#

Copy Code

publicclass TaxRates{ [XmlElement(ElementName ="TaxRate")]public decimal ReturnTaxRate;}

For more information about attributes, seeExtending Metadata Using Attributes. For a list of attributes that control XML serialization, seeAttributes That Control XML Serialization.

Best Regards

Monday, March 26, 2012

Change Accordian SelectedIndex in the client

How do I changed the SelectedIndex of an Accordian control at runtime from the client in JavaScript. The SelectedIndex property doesn't appear to be there nor can I find a comparable in the attributes.Hi Vegivore,

You can just callmyAccordion.set_SelectedIndex(i);. If you're not seeing this property, you should try getting the latest version of the Toolkit.

Thanks,
Ted

I tried this a few different ways - but I always get "Object doesn't support this property or method"

I downloaded the latest (i think) - no difference.

Microsoft.Web.Atlas.dll - 9/19/06

AtlasControlToolkit.dll - 9/15/06

Microsoft.AtlasControlExtender.dll - 9/19/06

Do I have the right builds?

Here's the relevant code:

aspx file:

<atlasToolkit:Accordion

ID="accHost"

...

javascript file:

var accHost = document.getElementById('accHost');

accHost.set_SelectedIndex(i);


Hi Vegivore,

Okay - I see your problem now. You should usevar accHost = $object('accHost_AccordionProperties');. You need to get the "Atlas" behavior instance instead of the DOM element.

Also - I don't think you should have the Microsoft.AtlasControlExtender.dll anymore... we merged that in with the rest of the Toolkit's AtlasControlToolkit.dll.

Thanks,
Ted


Perfect! Works great.

Thanks Ted


Are old threads still checked? If so, how would one access the Accordion, client side, when it is embedded in a <UpdatePane>...<Multiview>...<View><Atlas:Accordion...

Using the code above I get 'undefined'. (Obviously I've changed accHost for my own control name)

var myAcc = $object('results_AccordionProperties');

myAcc is always undefined.

Angel


Hi Angel,

When responding to an old thread it bumps it to the top of the list. The three Microsoft team members had been neglecting the forums to get our last release out the door but we'll always try to answer each post eventually.

I'm guessing that yourAccordion'sClientID is something more complicated than justresults (because it's probably in a naming container). You should replace results with whatever itsClientID is to get it working. If that's not the issue, please keep posting.

Thanks,
Ted

Ted,

I'm having an issue also doing this. I've read your various posts around the forum and this is what my code currently boils down to:

"theAccordion"
runat="Server"
SelectedIndex="0"
HeaderCssClass="orderHeader"
ContentCssClass="orderContent"
AutoSize="None"
Width="500"
FadeTransitions="true"
TransitionDuration="250"
FramesPerSecond="40"
BehaviorID="theAccordion"
ClientID="theAccordion"
"orderHeader"
ContentCssClass="orderContent"
ID="AP1">
Choose your template:
Step 1 Content
"server" ID="step1next" Text="Next >"
"orderHeader"
ContentCssClass="orderContent"
ID="AP2">
Select Output Options:
Step 2 Content
"server" ID="step2prev" Text="< Prev">
"server" ID="step2next" Text="Next >"
"orderHeader"
ContentCssClass="orderContent">
Enter Details:
Step 3 Content
"server" ID="step3prev" Text="< Prev">
"server" ID="step3next" Text="Next >"
"orderHeader"
ContentCssClass="orderContent">
Preview Order:
Step 4 Content
"server" ID="step4prev" Text="< Prev">
"server" ID="step4next" Text="Next >"
"orderHeader"
ContentCssClass="orderContent">
Submit Order:
Step 5 Content
"server" ID="step5prev" Text="< Prev">
"server" ID="step5next" Text="Finish"
"javascript" type="text/javascript"> function GoNext() { var accordion = $find('theAccordion_AccordionBehavior'); accordion.set_SelectedIndex(1); }

I get a JS error of "accordion has no properties" on the "accordion.set_SelectedIndex(1);" line.

Help!


The code-paster botched my code - here it is sans-highlight:

<%@. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" validateRequest="false" CodeFile="Order.aspx.cs" Inherits="_Default" Title="Order" EnableEventValidation="false" EnableViewState="false"%
<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PageTitle" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="JavaScript" Runat="Server">
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="SectionName" runat="server">Place/Edit Order</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="MainContent" Runat="Server"
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
<asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
<ContentTemplate>
<asp:SqlDataSource runat="server" ConnectionString="<%$ ConnectionStrings: CappSql %>" ID="DSTemplateList" SelectCommand="SELECT TemplateID,TemplateName FROM (SELECT TemplateID,TemplateName FROM Templates UNION SELECT 0 as TemplateID, '' as TemplateName FROM Templates) A ORDER BY TemplateID"></asp:SqlDataSource>
<table width="85%">
<tr>
<td valign="top">
<asp:Wizard ID="Wizard1" runat="server" Width="100%" Height="100%" Visible="false" SideBarStyle-VerticalAlign="Top">
<HeaderStyle VerticalAlign="Top" />
<SideBarStyle Wrap="False" />
<WizardSteps>
<asp:WizardStep ID="WizardStep1" runat="server" Title="Choose a Template" StepType="Start">
Choose your template:
<asp:DropDownList ID="TemplateList" runat="server" AutoPostBack="True" DataSourceID="DSTemplateList" DataTextField="TemplateName" DataValueField="TemplateID"></asp:DropDownList>
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" Title="Select Output Options">
Output Type:<br />
<asp:RadioButtonList ID="OutputType" runat="server" AutoPostBack="True">
<asp:ListItem Enabled="False" Value="pdf" Text="PDF"></asp:ListItem>
<asp:ListItem Enabled="False" Value="html" Text="HTML"></asp:ListItem>
</asp:RadioButtonList>
<asp:CheckBox ID="Printing" runat="server" Value="Printing" Text="Printing" Enabled="false" AutoPostBack="True"/>
<asp:Panel ID="PrintingDetails" runat="server" Visible="false">
Print details here
</asp:Panel>
</asp:WizardStep>
<asp:WizardStep ID="WizardStep3" runat="server" Title="Enter Details">
<table border="0" cellpadding="0" cellspacing="0">
<asp:Panel ID="DetailsPanel" runat="server" EnableViewState="true"></asp:Panel>
</table>
</asp:WizardStep>
<asp:WizardStep ID="WizardStep4" runat="server" Title="Preview Order">
<asp:HyperLink ID="PreviewOrder" runat="server" Target="_blank">Preview Order</asp:HyperLink>
</asp:WizardStep>
<asp:WizardStep ID="WizardStep5" runat="server" Title="Submit Order" StepType="Complete">
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
<asp:HiddenField ID="OrderID" runat="server" />
</td>
<td valign="top" width="300">
<asp:Label ID="Label1" runat="server" Text="Current Template" Visible="false" Font-Bold="true"></asp:Label><br />
<asp:Image ID="pdfImage" runat="server" Visible="false" Width="272" Height="352" BorderWidth="1" style="position:fixed"/>
</td>
</tr>
</table>
<table><tr><td><asp:Label ID="lblStateInformation" runat="server"></asp:Label></td></tr></table>
<div style="margin-left:auto; margin-right:auto;">
<cc1:Accordion
ID="theAccordion"
runat="Server"
SelectedIndex="0"
HeaderCssClass="orderHeader"
ContentCssClass="orderContent"
AutoSize="None"
Width="500"
FadeTransitions="true"
TransitionDuration="250"
FramesPerSecond="40"
BehaviorID="theAccordion"
ClientID="theAccordion">
<Panes>
<cc1:AccordionPane
HeaderCssClass="orderHeader"
ContentCssClass="orderContent"
ID="AP1">
<Header>Choose your template:</Header>
<Content> Step 1 Content <br /><asp:Button runat="server" ID="step1next" Text="Next >"></asp:Button></Content>
</cc1:AccordionPane>
<cc1:AccordionPane
HeaderCssClass="orderHeader"
ContentCssClass="orderContent"
ID="AP2">
<Header>Select Output Options:</Header>
<Content> Step 2 Content
<asp:Button runat="server" ID="step2prev" Text="< Prev"></asp:Button>
<asp:Button runat="server" ID="step2next" Text="Next >"></asp:Button>
</Content>
</cc1:AccordionPane>
<cc1:AccordionPane
HeaderCssClass="orderHeader"
ContentCssClass="orderContent">
<Header>Enter Details:</Header>
<Content> Step 3 Content
<asp:Button runat="server" ID="step3prev" Text="< Prev"></asp:Button>
<asp:Button runat="server" ID="step3next" Text="Next >"></asp:Button>
</Content>
</cc1:AccordionPane>
<cc1:AccordionPane
HeaderCssClass="orderHeader"
ContentCssClass="orderContent">
<Header>Preview Order:</Header>
<Content> Step 4 Content
<asp:Button runat="server" ID="step4prev" Text="< Prev"></asp:Button>
<asp:Button runat="server" ID="step4next" Text="Next >"></asp:Button>
</Content>
</cc1:AccordionPane>
<cc1:AccordionPane
HeaderCssClass="orderHeader"
ContentCssClass="orderContent">
<Header>Submit Order:</Header>
<Content> Step 5 Content
<asp:Button runat="server" ID="step5prev" Text="< Prev"></asp:Button>
<asp:Button runat="server" ID="step5next" Text="Finish"></asp:Button>
</Content>
</cc1:AccordionPane>
</Panes>
<HeaderTemplate></HeaderTemplate>
<ContentTemplate></ContentTemplate>
</cc1:Accordion>
</div>
<script language="javascript" type="text/javascript">
function GoNext()
{
// Find the behavior instance
//alert(MyAccordion.SelectedIndex);
//MyAccordion.set_SelectedIndex(MyAccordion.SelectedIndex + 1);
var accordion = $find('theAccordion_AccordionBehavior');
accordion.set_SelectedIndex(1);
//alert(accordion);
/*if (!behavior) continue;

// Open or close the panel
if (open)
{
behavior._doOpen();
}
else
{
behavior._doClose();
}*/
}
</script>
</ContentTemplate>
</asp:UpdatePanel>

</asp:Content


Hello, did you ever find out of your problem? i have the same problem. I am using the tab controll and when i change tabs i need to open the right accordian pane.

var accordion = $find('accEquityModels_AccordionBehavior');

accordion.set_SelectedIndex(2);


I'm hoping to get an answer on this question "how to change the index from javascript"

I've got and accordion with the id "Accordion1" inside a Content Page of a Master Page, and the full client ID of it is: "Master_MainContent_Accordion1" (That's according to the ".ClientID" property in code)

that ID is all through the generated HTML as is "Master_ctl04_Accordion1" (i have no idea what that is looking at, there for sure is only one ajaxToolKit:Accordion declared)

in my javascript, both

var accordion = $find('Master_MainContent_Accordion1_AccordionBehavior');
var accordion = $find('Master_ctl04_Accordion1_AccordionBehavior');

return "null"

any ideas?


Found my own answer: http://blog.benhall.me.uk/2007/01/aspnet-ajax-accordion-control-change.html

Hope that helps others down the road

causing validation from client side without postback?

Now that I added callout extenders to my validators how can I get them to work 1- on the client before calling an AJAX webservice and 2- in the webservice? I am not using an update panel so can I turn off server side validation and write my own for the webservice to call?

Hi Echo,

Echo88:

Now that I added callout extenders to my validators how can I get them to work 1- on the client before calling an AJAX webservice and 2- in the webservice? I am not using an update panel so can I turn off server side validation and write my own for the webservice to call?

My understanding of your issue is that you want to validate the inputs. If all these are correct then call the WebService ,otherwise, show the error message by using ValidatorCalloutExtender. If I have misunderstood, please feel free to let me know.

Validators are call before the form is submitted , but to call the WebService we don't need to postback. So I suggest that you should write your own validate Javascript code instead of ValidatorCalloutExtender controls.

Here is the sample to call a WebService.

<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="DataTableService.asmx" InlineScript="true" />
</Services>
</asp:ScriptManager
<input type="button" value="Get DataTable" onclick="getDataTable();" /
<div id="result"></div
<script language="javascript" type="text/javascript">
function getDataTable()
{
DataTableService.GetDataTable(onSucceeded, onFailed);
}

function onSucceeded(result)
{
//handle code
}

function onFailed(error)
{
//handle code
}

You can also transfer all the inputs and validate on the server side in the WebService.

I hope this help.

Best regards,

Jonathan


Thanks - sucks that I can not use those jazzy callouts. But a question I have is - doesn't it call a client script prior to postback?? My understanding is that validation takes place before posting the form data to the server, so one would think there is a call to a script that precedes the actual postback. Am I wrong?


Hi Echo88,

But a question I have is - doesn't it call a client script prior to postback??

Yes , you are right. The problem is that if all the inputs are correct , the form will postback next. But to call a webservice , we usually do not need to postback. It will cause the page refreshment. Based on this , I think write your own Javascript function is a better way in this situation. If you don't want to validate on the client side , you can also transfer all the inputs to the server side and validate on the WebService.

function setBoy()
{
var boy = new Object();
boy.Name = "Terry";
var girl = new Object();
girl.Name = "Mary";
boy.GirlFriend = girl;

BoyGirlService.SetBoyWithGirlFriend(boy, onSetBoySucceeded, onFailed); // call the WebService.
}

I hope this help.

Best regards,

Jonathan


exactly - I am calling a webservice instead of a postback. But am I right to say there should be a way to cause validation on the client - regardless of postback? I just thought there would be a method to execute independently. What aboutPage_ClientValidate() ??


Hi Echo88,

Yes , I agree with you. You can use it like this.

Button1.Attributes["OnClick"] = "Javascript:if (typeof(Page_ClientValidate) == 'function') if(Page_ClientValidate()) {return confirm('Are you sure to submit ?'); } else return false;";

Best regards,

Jonathan


I tried that - no dice. The button is set to cause validation and uses submit behavior. However, nothing is happening? I guess it is not finding Page_ClientValidate function. When include Page_ClientValidate by itself - it throws an error. So why is not included?


Hi Echo88,

Sorry for the delay. Here is my test sample and it works pretty well.

<%@. 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 Page_Load(object sender, EventArgs e) { Button1.Attributes["OnClick"] = "Javascript:if (typeof(Page_ClientValidate) == 'function') if(Page_ClientValidate()) {return confirm('Are you sure to submit ?'); } else return false;"; }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"><%=DateTime.Now.ToString()%> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox1"></asp:RequiredFieldValidator> <asp:Button ID="Button1" runat="server" Text="Button" UseSubmitBehavior="true" CausesValidation="true" /> </form></body></html>
So please compare it with yours and if it doesn't work, please feel free to let me know with more information. Thanks.

Best regards,

Jonathan


Your example works - even though it does perform a postback - I turned off the submitbehavior. Still works:) so there is hope- I suspect the

Page_ClientValidate function is not getting generated somehow. Could the fact that I am using them all as part of a user control be the problem?
Thanks - its really appreciated. 

Ok - I found out something interesting... The Page_Validators array is not populating on this one page. Any ideas why they are not populating Page_Validators ?


OK - I found the root of the cause. In my control I have readonly mode that would make all validators invisible if it was in readonly mode. Apparently, I did set the function incorrectly and all validators were not being rendered.

Causing postback

I have written some javascript that async calls a webservice every second. If the service returns true, I want to cause a postback, with client script that can be handled on the server and tell a particular update panel to update in the server side handler.

I also wish to construct event arguments on the client to be passed as part of the post back.

How do I do this?

I need to do something similar, and I'm wondering if you could do it by having your page implement the IPostBackEventHandler. This interface requires that you implement a RaisePostBackEvent method. This method takes a string argument, and you could update your updatepanels in this method. Does anyone know if this approach would work?

Thanks,

Nick


hello.

ipostbackeventhandler is not the answer if you need to update updatepanels. what you could do is:

1. use the postbackaction

2. add a hidden dummy button to the updatepanel and force the submit by calling its click method


Nope, dont need to do that. ipostbackeventhandler is the way to go.

I add some javascript to the page via:

Microsoft.Web.UI.ScriptManager.RegisterClientScriptBlock(
this,
this.GetType(),
"UIService_Agent",
string.Format(
"function CheckAgentTimer()" +
"{{" +
"UIService.ShouldInteruptAgent(OnAgentTimerSucceeded,OnAgentTimerFailure);" +
"}}" +
"function OnAgentTimerSucceeded(result)" +
"{{" +
"if(eval(result))" +
"{{" +
"{0};" +
"}}" +
"setTimeout(\"CheckAgentTimer()\",{1});" +
"}}" +
"function OnAgentTimerFailure()" +
"{{" +
"setTimeout(\"CheckAgentTimer()\",60000);" +
"}}" +
"setTimeout(\"CheckAgentTimer()\",10000);",
this.Page.ClientScript.GetPostBackEventReference(this,AgentTasksTimer.AGENT_PROCESS),
this.timerInterval
),
true);

and then I implement the interface ipostbackeventhandler


public void RaisePostBackEvent(string eventArgument)
{
if (eventArgument == AGENT_PROCESS)
{
//Is There Work for the Agent?
if (WorkItemActionRequired != null && IsWorkItemActionRequired())
{
WorkItemActionRequired(this, new WorkItemEventArgs(ResourceReceiverService.GetUserWork(((IUserPrincipal)Context.User).Credentials.UserId, true)));
}
}
}

Messy I know, but bare with me...

You can then request that update panels are updated on the server i.e. myUpdatePanel.Update

This works!


Luis Abreu:

hello.

ipostbackeventhandler is not the answer if you need to update updatepanels. what you could do is:

1. use the postbackaction

2. add a hidden dummy button to the updatepanel and force the submit by calling its click method

How do you call the click method on a hidden dummy button?


hello.

you must get ?a refernce for the html control and call its click method:

$get("your_button_client_side_id").click();

But will this cause a partial or full post back?

Thanks,

Nick


hello.

it depend: if it's an asp.net button and it's placed inside an updatepanel (or if it's outside the updatepanel but it's configured as a trigger) you'll get a partial postback.

That might do the trick then. Right now I have implemented IPostBackHandler, but it causes a full post-back. I just want to do a partial. How do I make the button invisible, set Visible to false, or set visible to hidden in the button style?

Thanks,

Nick


hello.

it depend: if it's an asp.net button and it's placed inside an updatepanel (or if it's outside the updatepanel but it's configured as a trigger) you'll get a partial postback.
hello again.
well, i'd just add syle="display:none" in the asp.net button declaration.

This will also allow me to put code server-side?

Thanks,

Nick

CascadingDropDowns cant fire OnSelectedIndexChanged client events?

Greetings, all...

I've got a page with a CascadingDropDown setup. On the third dropdown, I want to fire an update panel event to fetch data.

For whatever reason, it does not appear that I can get any of the three dropdowns in the cascade to recognize a client-side OnSelectedIndexChanged event - even when added programmatically in the code file.

The event/action are emitted correctly to the control, but it doesn't seem to fire the event.

I've been trying to find the answer in previous posts and Google, but I don't seem to be finding the answers anywhere. I'm hoping there's someone out in forumland that has seen this before and knows how to resolve the issue.

Thanks in advance for the help,

Ric Castagna

Unless I'm mistaken, OnSelectedIndexChanged is a server-side event, not a client-side one.

Saturday, March 24, 2012

CascadingDropDown: How to register OnChange event on client?

Hello,

I have a WebForm with three CascadingDropDown. First is the parent of second list and second is the parent of the third list. And third list has a AutoPostBack feature to populate a GridView in an UpdatePanel on the page. My challenge is clear UpdatePanel content when user change first or second lists value.

So how can I register to onChange something like event of the list on client script? Then I can use $get("UpdatePanelClientId").innerHTML="".


Regards.

Hi,

You may use the following code.

<asp:DropDownList ID="DropDownList1" runat="server" Width="170"onchange="$get('ctl00_SampleContent_UpdatePanel1').innerHTML='';"/>

You can try it on the sample website's CascadingDropDown.aspx page.

Hope this helps.

Wednesday, March 21, 2012

CascadingDropDown incompatible with WebServices using GET?

I'm using a trio of cascadingdropdowns representing country/state/city throughout a web application I'm developing for a client. They've recently reduced their internet speed dramatically (from 7mbps to 728k) and suddenly I've had to become more concerned about bandwidth usage.

I'd like to switch my webservice to use GET so that client browsers can cache the results without re-requesting from the server, unfortunately when I try, my select boxes show the error: 12030 (occasionally 12031)

WebService Code:

1<Services.WebMethod(cacheduration:=60), Script.Services.ScriptMethod()> _2Public Function GetCountries(ByVal knownCategoryValuesAs String,ByVal categoryAs String)As CascadingDropDownNameValue()3Dim cachedurationAs TimeSpan = TimeSpan.FromMinutes(1)4Dim maxageAs System.Reflection.FieldInfo = HttpContext.Current.Response.Cache.GetType().GetField("_maxAge", Reflection.BindingFlags.InstanceOr Reflection.BindingFlags.NonPublic)5 maxage.SetValue(HttpContext.Current.Response.Cache, cacheduration)6 Context.Response.Cache.SetCacheability(HttpCacheability.Public)7 Context.Response.Cache.SetExpires(Now.Add(cacheduration))8 Context.Response.Cache.AppendCacheExtension("must-revalidate, proxy-revalidate")9Dim cadapterAs New ltcodebehind.DSTablesTableAdapters.countryTableAdapter10Dim ctableAs New ltcodebehind.DSTables.countryDataTable11 cadapter.Fill(ctable)12Dim valuesAs New List(Of CascadingDropDownNameValue)13For iAs Integer = 0To ctable.Count - 114 values.Add(New CascadingDropDownNameValue(ctable(i).Title, ctable(i).ID))15Next1617 Return values.ToArray1819End Function

Client source code

1 <asp:ScriptManager runat="server" ID="acm1" >23 </asp:ScriptManager>4 <ajaxtoolkit:CascadingDropDown runat="server" ID="atlascascmgr" ServicePath="../Services/skService.asmx" SelectedValue="229" Category="country" ServiceMethod="GetCountries" TargetControlID="ddlcountry" />5 Country<br />6 <asp:DropDownList ID="ddlcountry" runat="server" />

Some notes

The only different on whether I receive an error 12030 is whether I have theusehttpget:=Truein the scriptmethod, so my cascadingdropdowns are configured properly for POST operations, I specifically need to know what I can change to get it to accept GET operations.

Usually its around this time that someone might offer up serverside caching, so I'm going to go ahead and answer that question now. 1) I appreciate the goodwill, I'm not being snarky, just trying to preemptively headd of the answer 2) I'm caching the webservice via the cacheduration:=60 up above, it just doesn't help because the server has power to spare, its the clients browsers that need the help.

Thanks everyone for their potential answers. :)

The third parameter to ASP.NET AJAX's Sys.Net.WebServiceProxy.invoke method is called "useGet" and tells it whether to use GET or POST for the web service call. The Toolkit's CascadingDropDownBehavior.js currently hard-codes this parameter to false (meaning "use POST"), so that's likely the source of the problem here. You should be able to change the value to true and rebuild for your client. If that works for you, pleaseopen a work item to ask that we expose this setting as a parameter to CascadingDropDown extender itself so that it will be easy to change for others who might want to do so. Thank you!

Very interesting, I'll do it when I have the time and if it works, open the work item like you describe.

Thanks!