Showing posts with label update. Show all posts
Showing posts with label update. Show all posts

Wednesday, March 28, 2012

Change to invokeViaServer method

Why was the old ModalPopupBehavior.invokeViaServer method changed to remove the section that deals with the partial page update? I was using that method, and now that I'm migrating to the new code base .. I'm just a little confused.

Also, has anyone explained publically why getDescriptors is now gone?

getDescriptors is gone because the ASP.NET AJAX Beta (referred to as "Core") no longer supports TypeDescriptor. That stuff was mostly there to support XML Script, so it was no longer needed.

For the invokeViaServer stuff, much of that code shouldn't be needed anymore. I didn't do the work on that component so I'm not completely sure (David did the work and he's out of the office this week) if it's critical or not. Try it as is and report back if it's not doing the right thing. The way that components get called after a partial update has changed, it may address this scenario.


Oh, so .. was XML Script scraped? So many breaking changes for developers .. ^_^ Yea, I was using the invokeViaServer method for a few controls of mine, and was curious about the change while I was trying to migrate from the last CTP to the Beta. With so many changes, it's hard to tell. You can't see the list of check-in notes *easily* on the Codeplex site, which is where some of the documentation is going.

Even if you could, it probably wouldn't help. The number of checkins associated with the migration was well into the hundreds I'm sure (basically 3-6 people working 12+ hours a day for 2.5 weeks...) so it would be hard to pick things out.

Your better bet is to check out the migration materials onhttp://ajax.asp.net and my blog entry(s) on the subject athttp://blogs.msdn.com/sburke.

Change TextBox Text and Force UpdatePanel to Update

Can somebody show me a way of forcing an updatepanel to update using javascript.

Thanks

Hi~ Once I used a button to trigger the update and invoked the button.click() in javascript..

I know this is not some elegant solution.. but you can give it a try when there's no better way~

change scroll position on partial-page update?

I'm wanting to be able to change the scroll position to the bottom (or to an anchor) on an AJAX partial-page update. Any ideas? Can I fire a client-side javascript function after the update? Do I have to turn off MaintainScrollPositionOnPostback for the page?

Seehttp://forums.asp.net/t/1157991.aspx

Also, if you have specific scrolling logic when the UpdatePanel comes back, you can add it to EndRequest method in the following code (e.g. scrollTo)...

<script language="javascript" type="text/javascript"> var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_initializeRequest(InitializeRequest); prm.add_endRequest(EndRequest); function InitializeRequest(sender, args) { ... } function EndRequest(sender, args) { ... } </script>

-Damien


Thanks... that's what I needed!

Brad


http://aspnet.4guysfromrolla.com/articles/111704-1.aspx

<pages smartNavigation="true"MaintainScrollPositionOnPostback="true"/>

Try this also

<script type="text/javascript"
var prm = Sys.WebForms.PageRequestManager.getInstance();

prm.add_beginRequest(beginRequest);

function beginRequest()
{
prm._scrollPosition = null;
}

</script>

Lety me know if this helpful to you

change mouse pointer on AJAX UPDATE

i can't understand why i do same page exacly the same (copy & past) and sometimes it worked OK sometime it said javascript error.

My goal is to Change mouse pointer while AJAX is updating something and after finishes to change it back. I have found some woderfull example

please take a look at it:

<%@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Untitled Page</title>

</head>

<body>

<formid="form1"runat="server">

<div>

<asp:ScriptManagerID="ScriptManager1"runat="server">

</asp:ScriptManager>

<scriptlanguage="javascript"type="text/javascript">

var prm = Sys.WebForms.PageRequestManager.getInstance();

prm.add_initializeRequest(InitializeRequest);

prm.add_endRequest(EndRequest);

function InitializeRequest(sender, args)

{

$get('Container').style.cursor ='wait';

// Get a reference to the element that raised the postback,

// and disables it.

$get(args._postBackElement.id).disabled =true;

}

function EndRequest(sender, args)

{

$get('Container').style.cursor ='auto';

// Get a reference to the element that raised the postback

// which is completing, and enable it.

$get(sender._postBackSettings.sourceElement.id).disabled =false;

}

</script>

<asp:UpdatePanelID="UpdatePanel1"runat="server">

<ContentTemplate>

<asp:LabelID="Label1"runat="server"Text="Update Me"></asp:Label>

<br/>

<br/>

<asp:ButtonID="Button1"runat="server"OnClick="Button1_Click"Text="Button"/>

</ContentTemplate>

</asp:UpdatePanel>

</div>

</form>

</body>

</html>

whats wrong here?

hello.

well, i think that the code you've written will only change the cursor when it's over the container html control. btw, i'm not finding that control on the page you've posted...


well it worked few times. Here is a link to the original sample:

http://encosia.com/2007/01/01/improved-progress-indication-with-aspnet-ajax/

look at it and maybe it will be more clearer what i am up to


hello.

well, but in the case of that sample, the complete form is wrapped by a div element which is named container (and that's why the cursor changes with the previous code)...


ok so what would be my solution not nesceserily this particular one but i have an AJAX based website with master page and multiple content pages and i need

notify user when ajax completes any given task Best and many years know way is to change mouse cursor How can i do that besides this example? or maybe it needs some corrections?


hello.

i haven't run the example, but i think it's working. what i'm trying to tell you is that you're missing a div. if you look at the sample, you should see that the first child of the body is a div element named container. when you start a partial postback, it'll change the cursor for that element. since it is the top element, that means that while the mouse cursor is over the space ocuppied by the div, you'll see that cursor during a partial postback. since you don't have this div in the code you've shown, i'm assuming that it simply doesn't work.

you must keep in mind is that you'll only see that cursor when the mouse is OVER that element!


Thank you very much


one more thing i would like to ask you Now i put my master page in div with specified tag So if press any button it changes mouse cursor but if i hover onto a other button or textbox it changes cursor to default state only if am hovering onto label or sometext data i can see hourglass How can do that if something is going on no matter where you put your mouse on the DIV container the cursor still would be a hourglass?

Change full postback action from inner update panel...

Hi,

Is there a way to alter full postback to partial postback caused by outer update panels from usercontrol?Huh?Confused...I tried to add button control as an AsyncPostBackTrigger. No effect to change from a full page postback to partial one. No change whether I set properties like ChildrenAsTriggers to false/true and UpdateMode to Always/Conditional inner update panel, when a button or any control causes a postback action is pressed, it causes a full postback.


Parent:

<asp:UpdatePanel ID="upanelPage" ChildrenAsTriggers="false" UpdateMode="Conditional" runat="server">
<Triggers>
</Triggers>
<ContentTemplate>
<asp:UpdatePanel ID="upanelMainContent" ChildrenAsTriggers="false" UpdateMode="Conditional" runat="server">
<Triggers>
</Triggers>
<ContentTemplate>
<!-- Main Content --> <<-- my user control or other are displayed
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>

User Control loaded to Parent...

<asp:UpdatePanel ID="updatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" >
<ContentTemplate>
<ajaxToolkit:TabContainer ...>
<ajaxToolkit:TabPanel ...>
<asp:MultiView...>
<asp:View...>
...
<asp:LinkButton...></asp:LinkButton>
<asp:Button...></asp:Button>
<asp:UpdatePanel ...>
<Triggers>
<asp:AsyncPostBackTrigger ControlID=.../>
</Triggers>
<ContentTemplate>
...
<asp:GridView...>
</asp:GridView>
...
</ContentTemplate>
</asp:UpdatePanel>
...
</asp:View...>
<asp:View...>
...controls...
</asp:View>
</asp:MultiView>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ...>

</ajaxToolkit:TabPanel>
...
</ajaxToolkit:TabContainer>
</ContentTemplate>
</asp:UpdatePanel>

UpdatePanel causes a Full Post Back no matter what properties you set on it.

If you are looking for better performing alternatives, look out for ScriptCallbacks or JSON Based Calls and this would require "some" work compared to ourmagic updatepanel!


Huh??ConfusedScriptCallbacks?ConfusedJSon Based Calls?Hmm...Does not know what are they or how to start with them? ..thanks for the reply..


Huh??ConfusedScriptCallbacks?ConfusedJSon Based Calls?Hmm...Does not know what are they or how to start with them? I was trying to control the postback action of outer update panel from the inside user control..thanks for the reply..


Hi,den2005

I found that the following code worked.

The Page:

<%@. Page Language="C#" %>

<%@. Register src="http://pics.10026.com/?src=WebUserControl2.ascx" TagName="WebUserControl2" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>UpdatePanel Tutorial</title>
<style type="text/css">
#UpdatePanel2 {
position: relative;
margin: 2% 5% 2% 5%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ChildrenAsTriggers="False" ID="UpdatePanel1" UpdateMode="Conditional"
runat="server">
<ContentTemplate>
<fieldset>
<legend>Parent UpdatePanel</legend>Last refresh
<%=DateTime.Now.ToString() %>
<br />
<asp:Button ID="Button1" runat="server" Text="Refresh Outer Panel" />
<uc1:WebUserControl2 ID="WebUserControl2_1" runat="server" />
</fieldset>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>

The UserControl:

<%@. Control Language="C#" ClassName="WebUserControl2" %>
<asp:UpdatePanel ChildrenAsTriggers="False" ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<fieldset>
<legend>Nested UpdatePanel</legend>Last refresh
<%=DateTime.Now.ToString() %>
<br />
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
</fieldset>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Calendar1" />
</Triggers>
</asp:UpdatePanel>

Hope this help.

Best regards.

Jin-Yu Yin

Change event in Ajax Update Panel

Dear All

If any event contains inside of the update panelthen after post back focus is lost. More clearly, LetTextbox1 and TextBox2 inside of the update panel.TextBox1 containsTextChanged event andthis event contains TextBox2.Focus(). But after post back it lost the focus.


Thanks

Aminul Bari

It should work just fine. Let me see if I understand what you are saying:

You've got an updatepanel.


Try to use SetFocus of ScriptManager

http://www.asp.net/AJAX/Documentation/Live/mref/O_T_System_Web_UI_ScriptManager_SetFocus.aspx


Thanks. Its working fine.

Change contents of an external update panel from within a seperate accordian panel?

I am trying to update the contents of an update panel from the event of changing the panel in the accordian control (located outside of the update panel I wish to update). When I try to creat a trigger the update panel does not see the button located inside the accordian control. Any suggestions?

Let me see if I can clarify my question further. I have a content container on a master page. Inside the content container I have a table with two cells. In the first cell I have am using the accordian control. when I click on one of the headers in the accordian control I want it to update an update panel in cell number 2. The content of the accordian panel will be just a brief headline and overview of what is displayed in the update panel in cell #2. My issue is that when trying to define triggers in the update panel in cell #2 it does not see any of the controls in cell #1. Any suggestions?

Thanks for any help you can provide.

Monday, March 26, 2012

Change a Label with HoverMenuExtender

Hi

I am using the AJAXHoverMenuExtender and it works great with panels. But I want theHoverMenuExtender1 to update a Label1 with new text andHoverMenuExtender2 to update same Label1 with another text?

Best Regards

Staffan

Staffan,


Is not clear what you want. Do you have a control inside your hoverMenu that should trigger an update to the labels or do you need your labels updated when the HoverMenu "pops-up"?

Cheers,


Sorry to be to short!

I want a Label outside the hovermenu to be updated when the hovermenu is trigged; so I don′t want a "hovering" text over the control that is triggering.

My web:
On the left side of the screen I have a lot of controls that I want the hovermenutriggering on (a mouseoverfunction).

On the right side of the screen I have explanation text of what every control (on the left) side do:
So when the user "hovers" over every control on the left side, the explantion text changes, and when no hovering is trigged the original text schould come back.

Hope I am much more clear! :)

STaffan


Hi, Staffan,

Is not clear yet what you want.

Is your lable in a updatepanel? Is the text of the lable populated with data from a database in a Asynpostback triggered by the hovermunu items?

Is the lable in the popup panel of the hovermunu?


Assuming that your lable is in an updatepanel,you can set a hidden button as an Asynpostback trigger of the Updatepanel. Then in the client mouseover events of your hovermunu items,you can fire the click event of the hidden button.In this condition,you should send the ID of the hovermenu item you clicked to the click event of the hidden button.

Certain events not firing on server (but they are in dev)

I have a small web app that uses an update panel. Its asyncpostback event fires and updates a session variable. In the process, the pageload event fires and repopulates the elements within my update panel. This works in my dev environment, but doesn't work when I publish the site to my website.

The session variable is updated like it should via asyncpostback, but the pageload event isn't fired. Thus my chart within the updatepanel isn't redrawn. I have ajax installed on the server and the appropriate dll's are in the bin folder.

Any idea why this is happening?

The only thing I can think of is there are differences in your web.config file.


The web.config goes along with the publish (I've even manually copied the file over)


hello.

that is strange because the load event will always fire during a postback. have you tried hosting the app in IIS in your development environment?


Yeah I knew the web.config file went though with the Publish, but I wans't sure if you were using the Publish option in Visual Studio or if you were manually publishing it by copying the dll and aspx files. I had a few ideas as to what might be causing the problem but I keep throwing those ideas out because it is working in your test environment. At this point, I can only take guesses. I dont think AJAX.net is the problem because your session is getting updated aysnc. Since all the code is the same in both environments, that ww know of, I would next try to figure out what is different. Are the dll files different in any way, specifically the ajax dll's. Also try manually deploying the site. I have had some publshing problems with Visual Studio 2005 when publishing to ftp (The host I was using had users experieincing problems with the publish not publishing correctly.) Although the problem I and my host had was more to deal with Visual Studio stopming over some security permssions.. dont ask me how, it just did.


I have manually copied the files to the server as well (it is sitting right next to my desktop on the same domain).


hum...well, not sure on the response your chart is returning from the server. there shoudln't be any problems with it since you're seeing it work on the dev machine. anyway, how about using fiddler to see the response returned from the server ?


fiddler.. hmmm... thats a new one on me. I'll check it out.


it's an http proxy. really good to see the contents sent to and from the browser:

http://www.fiddlertool.com/


It is weird, Have you fixed it?


No, not yet. It's strange that the async call works but the page load isn't firing.

Centering AlwaysVisibleControl?

I'm using an update progress control inside of an always visible control to communicate to users when my application is loading data. I want to center the control on the screen but have seen no way by which to do this. Has anyone figured out a way to position the AVC in the center of the browser screen? Is there a better way to do this?

In the html for your panel you define an outer div with width and height set to 100%, a transparent background and text centered. An inner div is set with a solid background and the top attrib set to 50% or some offset. The inner div will then be centered within the outer div.

centered update progress

Hi;

I usually have my update progress control on the top of the page but on long pages, the user can't see it.

On codeplex.com, when i insert some text on "Search Projects" (upper right) and hit the search button, an "Updating" message is showed on the center of the page and the rest of the page becomes gray. Can i get this same result using AJAX update progress?

Thanks in advance;

If that is what you want, you should probably use the ModalPopup control. Try it at: http://asp.net/AJAX/Control-Toolkit/Live/ModalPopup/ModalPopup.aspx


Pls checkout this link, it got some cool example of Moal Popup extenderhttp://mattberseth.com/blog/modalpopupextender


See this link for AJAX Progress bar in the middle of page

http://www.ajaxium.com/ajax-for-asp.net.aspx

CCS getting lost while doing partial rendering with update panel......

hi !!

Problem :: CSS style lost when upatepanel does Partial Rendering..

I have made one navigation menu in javascript.. And i have onmouseover and onmouseout script...

In this script i m chaning the font and background image of <td>

The code is like this :

<tdid="menuid1" class="menuFont"onmouseover="show_popup(1)"onmouseout="javascript:m_show=0;">

<aid="mlink1" class="menuLink"href="#">Link1</a>

</td>

And the style is like bolow...

<styletype="text/css">

.menuFont1{font-size:11px;background:url(jsInclude/images/menu/nav_off_bg.gif)repeat-x;style=CURSOR:pointer;COLOR:#000000;FONT-FAMILY:Tahoma,Verdana,Arial,Helvetica,ans-serif;TEXT-ALIGN:center;TEXT-DECORATION:none}

.menuLink {color:#666666;TEXT-DECORATION:none;font-weight:bold}

.submenuLink{COLOR:#FFFFFF;TEXT-DECORATION:none}

.submenuFont{font-size:11px;COLOR:#ffffff;FONT-FAMILY:Tahoma,Verdana,Arial,Helvetica,sans-serif;height:16px;background-COLOR:#7885FF;TEXT-ALIGN:left}

</style>

Now in my form i have one text box and on its text_changed event i m doing partial rendering with update panel...

But when the response comes..the CSS of menu got lost...

Can any one help me what is the reason for this?

There has to be a boat out on the horizon somewhere. ,

Cause Postback with a Clientside Javascript

Hello,

I'm attempting to, with use of Clientside Javascripts (called from a Flash movie), to cause a Postback that will allow me to update the content of a GridView on my ASP.NET AJAX Page.

I've spend a lot of time looking at the documentation for the clientside framework, but I haven't been lucky enough to find anything. I realize that this poses the problem of a control having to cause a postback - but is there some way to do this (some workarround)?

Regards,
Jonas

Hi Jonas,

The way I do it (and I'm not sure it's a best practice / it is certainly a workaround ;) ) is the following:

To cause a postback: let the javascript find a button on the page (a server-side button) (for example: document.getElementById('MyButton')

Then you can touch the click event of that button

Make that click event cause a full postback or a partial postback (callback) if the button is a trigger of an updatepanel.

I hope all makes sence.
If you have further questions/remarks I'd like to hear them.

Greetz
Wim


HI Jonas,

You can write a javascript function withdocument.aspnetForm.submit(); statement in it and call it from your Flash. This will cause a postback and you can update the content.



A call to Sys.WebForms.PageRequestManager.getInstance()._doPostBack() is a good way to do it.

Cause a JavaScript Function to run after update (update panel postback)

Hello,

I ran into a problem that im not sure if the Atlas framework addresses.

I need to fire off a javascript function (which is decided server side)on a postback. To do this I am going to be using a hidden input field.(since I already have one on the form I use to send information forserver use.) From the server side, I can place the function names intothe hidden input field. But I can't cause them to run, on each postback.

I suppose that is confusing, let me try something simpler.

1. I fire off a postback in javascript - This is done using the__dopostback() and the server side fires off its if statements and doesits functions based on what has been placed into my hidden input field.(this is all good so far) (if I had to I could use the body's on formload ability to fire off the javascript functions I desire, but thatwont work for the next step, and is really ugly)

2. I include Atlas to make my postback not refresh the whole page. This is done by using UpdatePanels.

3. On the server side I need to somehow tell it to run certainjavascript functions when that postback finishes loading. (so like onpartial page load)

How do I do step 3?<script type="text/javascript">
function AfterPostback()
{
alert("This is where we check the hidden input and run the functions.");
}

function PageRequestManagerPropertyChanged(sender, args)
{
if (args.get_propertyName() == "inPostBack")
{
if (!$object("_PageRequestManager").get_inPostBack())
AfterPostback();
}
}

function pageLoad()
{
$object("_PageRequestManager").propertyChanged.add(PageRequestManagerPropertyChanged);
}
</script
<div>
<atlas:ScriptManagerEnablePartialRendering="true" ID="ScriptManager1" runat="server">
</atlas:ScriptManager>
<atlas:UpdatePanel runat="server" Mode="Conditional" ID="UpdatePanel1">
<ContentTemplate>
<%= DateTime.Now.ToLongTimeString() %>
</ContentTemplate>
<Triggers>
<atlas:ControlEventTrigger ControlID="UpdateTime" EventName="Click"/>
</Triggers>
</atlas:UpdatePanel>
<asp:Button ID="UpdateTime" runat="server" Text="Update Time" />
</div
Thats the solution I rigged up.
Hi,

Thanks for posting your solution. It works very well and solves a whole bunch of missing stuff with AtlasPanels. One problem dough. I had to move the call to JS function pageLoad() to the end of the html file part instead of putting it to body onload event.
Another option for doing this is theUpdateProgressSignup extension.

Catch a Sys.WebForms.PageRequestManagerServerErrorException that occurs when server is dow

Hello,

I have an ajax timer control that updates an update panel every couple of seconds. When/if the server is down, there is an error message in a popup that says

"Sys.WebForms.PageRequestManagerServerErrorException: An unknown error ocurred while processing the request
on the server. The status code reutrned from the server was: 12029"

Basically I want to be able to catch this exception so that the popup does not continue to occur.

Is this possible?

Thanks in advance.

Take a look at the following posts on my blog:

http://fredrik.nsquared2.com/viewpost.aspx?PostID=395&showfeedback=true

http://fredrik.nsquared2.com/viewpost.aspx?PostID=394&showfeedback=true

You can also use the PageRequestManager, for example (This code should be located on the client):

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args)
{
if (args.get_error() != undefined)
{
var errorMessage;
if (args.get_response().get_statusCode() == '200')
{
errorMessage = args.get_error().message;
}
else
{
errorMessage = 'An unspecified error occurred. ';
}
args.set_errorHandled(true);
alert(errorMessage);
}
}


That's just what I needed. Thank you.

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.

Wednesday, March 21, 2012

CascadingDropDown in repeater

I have three dropdownlists, three cascadingdropdown extenders, and updatepanel within a repeater. I need to update a label control inside of the updatepanel when the selectedindexchanged event fires for the last dropdown. The problem I'm having is that the event doesn't seem to fire the first time the selectedindex is changed. It works as expected after changing the first time. Anyone have any ideas as to why this is happening. Here is my code.

<asp:RepeaterID="uxPublicationRepeater"OnItemDataBound="PublicationRepeater_ItemDataBound"OnItemCommand="Pub_ItemCommand"runat="server">

<ItemTemplate>

<ajax:CascadingDropDownID="uxPublicationCascading"runat="server"

Category="Publication"

ServiceMethod="GetPublicationsByMarket"TargetControlID="uxPubDropDownList"

ParentControlID="uxMarketDropDownList"PromptText="Select.."LoadingText="Loading.."/>

<ajax:CascadingDropDownID="uxPublicationYearCascading"runat="server"

Category="PublicationYear"PromptText="Select.."LoadingText="Loading.."

ServicePath="~/Services/LookupWebService.asmx"ServiceMethod="GetYearsByPublication"

TargetControlID="uxPublicationDateDropDownList"ParentControlID="uxPubDropDownList"/>

<asp:DropDownListID="uxMarketDropDownList"runat="server"/>

<asp:DropDownListID="uxPubDropDownList"runat="server"/>

<asp:DropDownListID="uxPublicationDateDropDownList"OnSelectedIndexChanged="IndexChanged"AutoPostBack="true"runat="server"/>

<asp:UpdatePanelID="uxUpdatePanel"ChildrenAsTriggers="false"UpdateMode="conditional"runat="server">

<ContentTemplate>

<asp:LabelID="uxLabel"runat="server"/>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTriggerControlID="uxPublicationDateDropDownList"EventName="SelectedIndexChanged"/>

</Triggers>

</asp:UpdatePanel>

</ItemTemplate>

</asp:Repeater>

Thanks for the help.

Have you taken a look at the sample?http://www.asp.net/AJAX/Control-Toolkit/Live/CascadingDropDown/CascadingDropDown.aspx

This could be related to EventValidation (see http://www.asp.net/AJAX/Control-Toolkit/Live/Walkthrough/CCDWithDB.aspx specfically:"Finally, in order for the values to be submitted, EventValidation needs to be disabled for the page. EventValidation ensures that the values in each control match the values that were present when the page was rendered, but since these drop downs are populating on the client side, this is never true.")

-Damien


I tried turning event validation off and still no good. The event fires the first time if the controls are outside of the repeater, but doens't fire until the second time when inside the repeater.


No one else has ran into this problem? If I take the cascadingdropdown extender out, the events fire correctly. Just to recap, dropdownlists in a repeater, selectedindexchange event fires correctly. Dropdownlists and cascadingdropdown extenders inside a repeater the event doesn't fire until the second time the selectedindex is changed. If anyone is interested I have a small sample app that illustrates the problem.


c.barnes01:

No one else has ran into this problem? If I take the cascadingdropdown extender out, the events fire correctly. Just to recap, dropdownlists in a repeater, selectedindexchange event fires correctly. Dropdownlists and cascadingdropdown extenders inside a repeater the event doesn't fire until the second time the selectedindex is changed. If anyone is interested I have a small sample app that illustrates the problem.

Hi,

I'd like to see your small sample, it will be preferred to use NorthWind database or a fake data source built in code.


Here is a small app that illustrates the problem.

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" EnableEventValidation="false" Inherits="_Default" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:Repeater ID="uxTestRepeater" OnItemDataBound="Repeater_DataBound" runat="server"> <ItemTemplate> <cc1:CascadingDropDown ID="uxCountriesCascading" Category="Countries" runat="server" ParentControlID="uxCountryDropDownList" TargetControlID="uxStatesDropDownList" LoadingText="Loading.." PromptText="Select.." ServiceMethod="GetScopedStates" /> <asp:DropDownList ID="uxCountryDropDownList" runat="server" /> <asp:DropDownList ID="uxStatesDropDownList" AutoPostBack="true" OnSelectedIndexChanged="SelectedIndex_Changed" runat="server" /><br /> <asp:UpdatePanel ID="uxUpdatePanel" runat="server"> <ContentTemplate> <asp:Label ID="uxStateLabel" runat="server" Text="Select a State" /> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="uxStatesDropDownList" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel> <hr /> </ItemTemplate> </asp:Repeater> </div> </form></body></html>

using System;using System.Collections;using System.Collections.Generic;using System.Collections.Specialized;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.Services;using System.Web.Script.Services;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using AjaxControlToolkit;public partialclass _Default : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) {if (!Page.IsPostBack) {this.uxTestRepeater.DataSource = GenerateRepeaterDataSource();this.uxTestRepeater.DataBind(); } }private List GenerateRepeaterDataSource() { List toReturn =new List(); toReturn.Add(new MyClass(1,"Chris"));return toReturn; }protected void Repeater_DataBound(object sender, RepeaterItemEventArgs e) { DropDownList countryDropDownList = e.Item.FindControl("uxCountryDropDownList")as DropDownList; countryDropDownList.DataSource = GenerateCountries(); countryDropDownList.DataTextField ="Value"; countryDropDownList.DataValueField ="Key"; countryDropDownList.DataBind(); }private Dictionary<int,string> GenerateCountries() { Dictionary<int,string> toReturn =new Dictionary<int,string>(); toReturn.Add(1,"USA"); toReturn.Add(2,"Canada"); toReturn.Add(3,"Mexico");return toReturn; }protected void SelectedIndex_Changed(object sender, EventArgs e) { DropDownList stateDropDown = senderas DropDownList; Label stateLabel = stateDropDown.NamingContainer.FindControl("uxStateLabel")as Label; stateLabel.Text = stateDropDown.SelectedItem.Text; } [WebMethod] [ScriptMethod]public static CascadingDropDownNameValue[] GetScopedStates(string knownCategoryValues,string category) { CascadingDropDownNameValue[] toReturn =null; StringDictionary values = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);if (values.Count == 1) {string key = values["undefined"];switch (key) {case"1": toReturn = GetStatesForUsa();break;case"2": toReturn = GetStatesForCanada();break;case"3": toReturn = GetStatesForMexico();break;default:break; } }return toReturn; }public static CascadingDropDownNameValue[] GetStatesForUsa() { CascadingDropDownNameValue[] toReturn =null; toReturn =new CascadingDropDownNameValue[5]; toReturn[0] =new CascadingDropDownNameValue("SC","1"); toReturn[1] =new CascadingDropDownNameValue("GA","2"); toReturn[2] =new CascadingDropDownNameValue("NY","3"); toReturn[3] =new CascadingDropDownNameValue("FL","4"); toReturn[4] =new CascadingDropDownNameValue("NC","5");return toReturn; }public static CascadingDropDownNameValue[] GetStatesForCanada() { CascadingDropDownNameValue[] toReturn =null; toReturn =new CascadingDropDownNameValue[5]; toReturn[0] =new CascadingDropDownNameValue("Saskatchewan","1"); toReturn[1] =new CascadingDropDownNameValue("Alberta","2"); toReturn[2] =new CascadingDropDownNameValue("British Columbia","3"); toReturn[3] =new CascadingDropDownNameValue("Nunavut","4"); toReturn[4] =new CascadingDropDownNameValue("Yukon","5");return toReturn; }public static CascadingDropDownNameValue[] GetStatesForMexico() { CascadingDropDownNameValue[] toReturn =null; toReturn =new CascadingDropDownNameValue[5]; toReturn[0] =new CascadingDropDownNameValue("Hidalgo","1"); toReturn[1] =new CascadingDropDownNameValue("Veracruz","2"); toReturn[2] =new CascadingDropDownNameValue("Puebla","3"); toReturn[3] =new CascadingDropDownNameValue("Durango","4"); toReturn[4] =new CascadingDropDownNameValue("Sonora","5");return toReturn; }}public class MyClass{private int id;public int ID {get {return id; }set { id =value; } }private string name;public string Name {get {return name; }set { name =value; } }public MyClass(int id,string name) {this.id = id;this.name = name; }}

I still haven't found a solution to this yet. Anyone have any suggestions?

Thanks


Bump


What is the full type name of the toReturn( List toReturn =new List();) object?


It should have been, List<MyClass> toReturn = new List<MyClass>();

thanks


I looked into it through, and found out that the reason is because the items are filled on client side.

1. On the first request( when isPostback is false ), there is no items in DDLState.

2. DDLState is filled when the page has been rendered in the browser

3. Select an item in the DDL to start a postback

4. The DDL tries to find the currentIndex( it's -1 since it can't be found ) and compares it with previousIndex( it's -1 since there is no item previously ) to see if a selectedChanged event should be fired. And it won't be fired because they are equal

5. On the second request, the previously posted item is kept in ViewState and subsequently added into DDLState's items collection

6. The previously index is 0 because the only item currently in DDLState matches the previous value. And currently posted item's value still doesn't exist, so currentIndex is -1. They are not equal, thus the SelectedIndexChanged event is fired.



Thanks for looking into the problem. It's weird that it works when not in a repeater.