Wednesday, March 28, 2012

How do I wire a javascript function to an update panel so it fires when the panel is updat

I have a list of location in an update panel and a virtual earth map w/ pushpin's representing each of the locations. My update panel works great for paging through the location list using some custom paging where a the panel updates when the paging buttons are clicked. What I'd like to be able to do though is wire up an event handler to the update panel so when it refreshes, my javascript function can make a page method call and get new set of pushpins to display on the virtual earth map.

a) How do I get a reference to the update panel in javascript?

b) What is the update panel event that I wire a call back method to?

Thanks!

Hi there, you can accomplish this by hooking up a client side event handler to the PageRequestManager pageLoading event. The event args will indicate the list of UpdatePanels that are getting refreshed, you can inspec the array and if the UpdatePanel that you are interested in is being refreshed call your function.

More info here:http://ajax.asp.net/docs/tutorials/usingMsAjaxLibrary/default.aspx

Thanks,
Federico


Federico,

Thanks for the reply. Because the ASP.NET forums are moderated, I literally just figured it out before receiveing your reply. The PageRequestManager in Beta 1 is awesome!

- James


Hi Frederico

Your link appears to be broken - do you happen to know a working link for this topic ?

Thanks,
Richard

How do i use Tabs in Ajax in asp.net application..

Hi, i have a asp.net web application which is production... and the client wants us to display the data using the userid... right now i am using a datagrid in a simple aspx page.. but since the user has asked for that request.. i want to have 5 (tabs each for a user Id) and then display the datagrid on it... how can i do this is an existing aspx page.

I have downloaded the ajax tool kit and i dont know from where to start... by data grid is simple... just displaying the data using.. a sql query and there are few links in the datagrids to navigates to other pages...

So can I use Ajax just for one page,,, and is there anything that i need to know that will hamper production when using Ajax..

any help ,ideas and code will be greatly appreciated

Regards

Karen

You can easily only use ajax on one page, and creating the tab thing should be quite simple. There is nothing that will tamper production, since ajax is essentially an extra dll that goes in the bin folder, and a couple of additions to web.config. If I was you I would just go ahead and get my feet wet. There are some excellent getting started tutorials on this site. Just click the Ajax menu at the top of the page.

Good luck!

/Klaus


Thank you Klaus i will look into it. can you pls give me some link to it..

Regards

Karen


Hi,

Thank you for your post!

It seems that you are really a newbie to AJAX and javascript,this is a good start point for your learning:ASP.NET AJAX Roadmap

And this is a good point to start with Toolkit:http://www.asp.net/ajax/ajaxcontroltoolkit/samples/

And in my opinion, <ASP.NET AJAX in action> is a decent book to learn ASP.NET AJAX.

If you have further questions ,let me know.

Best Regards,


Jin,

Thanks for the link... and yeah i am newbie to Ajax and javascript... i had worked on tabs when i was working on VB.6 and then it was so easy then and that was 3 yrs ago.

regards,

Karen

How do I use JavaScriptSerializer on only certain properties of an object?

I have an object that inherits from UserControl. I want to seralize certain properties in this object using JavaScriptSerializer (or another method that does the same thing). Unfortunatly, if I try to seralize the control itself, I get a crash.

I am forced to make another object that contains all the properties that need to be seralized. The properites in my control then refrence the properties of that object. Though this works, it leaves my control with a bunch of properties which are effectively nothing more than pointers to another object that exists soley to make javascript seralization to work.

Is there way around this? I want to be able to use JSON on a usercontrol and be able to specify which properties I want seralized to JSON.

Try using the ScriptIgnore attribute in the properties you don't want to be serialized.

Hope this helps,

Elias.


I tried to override every virutal property on usercontrol and I still got "Cannot get inner content of because the contents are not literal."Something in my base class (usercontrol) seems to be causing problems

How do I use javascript to force an UpDatePanel to Update

Hi, I am trying to find a simple way to force a specific update panel to refresh/update from a javascript function. The reason being that I am trying to build a simple calendar control, simular to that on the AJAX Control Toolbox site under PopUpControlhttp://atlas.asp.net/atlastoolkit/PopupControl/PopupControl.aspx, and I want the calendar to update if a date has been manually entered into the text box. I have found that you have to add an atrribute to the date input text box to invoke a call to a javascript function. (I am using the calendar control that I make inside of a gridview control which is enbeded inside of multiple levels of Update Panels and the TextBox.OnChange() event does not fire when inside of a gridview. So I added the following to the Page_Load event:TextBox.Attributes.Add("OnMouseLeave","javascriptFunction()") ) The problem that I am having is what to add to thejavascriptFunction()to force a specific UpDatePanel to refresh. I can get all of the panels to update using a "__doPostBack('DateControl$DateDisplay',''); "but there seems like that should be a simple way to force only one panel to update. I've tried to click on a hidden button using a javascript click() event, but I continuosly get the follwing javascript error: " Microsoft JScript runtime error: '_postbackSettings.async' is null or not an object " Is there a way to implement theUpdatePanel.Update() function directly from Javascript? Am I even going in the right direction? Could I call one of my code behind functions from javascript to perform the UpdatePanel.Update()?

So in simple terms, when building a control how can i update a specific UpdatePanel in the control through a javascript function?

Help Please!! Thanks!Big Smile

There is no direct support for updating just a single panel. You can mostly achieve it by setting all your panels to be Conditional and then calling Update on just the ones you want.

Thanks,

Eilon

How do I use external scripts in controls, with brittle-old-atlas?

Hi, I realise Atlas is still in preview, but unfortunately it doesnt stop customer's demands :(

I've a server control that will not work with Atlas. I've whittled the problem down to this external script line.

<script type='text/javascript'src='/AtlasWebSite1/WebResource.axd?d=Q25Q6XUyjAkwUhmccPLXSM0tUH1gG8pvBlJoQRJbY9aaHhPMSqiC1p5xfcybhbNW0&t=632864860774426576'></script
This is registered with Page.ClientScriptBlock (I know ASP.NET2 hasdifferent syntax, but my control needs to support .NET1.x so the codeis easier to leave as is - it works with ASP.NET2 just fine).

Here's the kicker, the embedded script referred to above is just a small JS file with everything commented out.

If I don't register the script, the page works, if I do register thescript, then my simple little page with an UpdatePanel fails to updatewhen a postback happens. Please refer to my earlier post on thesame problem for the actual aspx pagehttp://forums.asp.net/thread/1318847.aspx

The script line above appears in the rendered code in the correct place

<form name="form1" method="post" action="default.aspx" id="form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTUxNzQwOTU4NGRkq48mV8BeUZdYRTUdUDPaQYzABY0=" />
</div
<script type="text/javascript">
<!--
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
// -->
</script
<scriptsrc="/AtlasWebSite1/WebResource.axd?d=j0rVreGbmSimbg9M6s2qsQ2&t=632664387855935408"type="text/javascript"></script
<script type='text/javascript'src='/AtlasWebSite1/WebResource.axd?d=Q25Q6XUyjAkwUhmccPLXSM0tUH1gG8pvBlJoQRJbY9aaHhPMSqiC1p5xfcybhbNW0&t=632864860774426576'></script>
<scriptsrc="/AtlasWebSite1/WebResource.axd?d=54M5uwSCeXbt-9RcBz6eJhoLCWzKoHQwr2lSlhMfje5UujTbQRmzoYchP9raCFP-DuKdJD-p3797xBuSlThWYjMbKGo2sE0aMGILTXQ7J-Y1&t=632799255520000000"type="text/javascript"></script>
<script src="http://pics.10026.com/?src=atlasglob.axd" type="text/javascript"></script>
<div>
<div id="UpdatePanel1">

Any and all help gratefully received, thanks!

JimHas nobody else experienced this?

I've reproduced it with a simple control that does nothing more than register an embedded script (which is empty).

Thanks
Jim
Turns out it works OK in Firefox, just not in IE6. Kind of ironic.

Please somebody, put me out of my misery!

Jim

Nevermind, I've had to work around it, looks like a bug in Atlas :(

How do I use Animation without server-side controls? (mission impossible?)

Hello everyone,

I post this question again, since I made some more investigations.

The question is how do I use Animation without server-side controls?

I understand that what I need is:

1. Some scripts. I think this is the complete list:
<scriptsrc="bin/MicrosoftAjax.js"type="text/javascript"></script>
<scriptsrc="bin/MicrosoftAjaxWebForms.js"type="text/javascript"></script>
<scriptsrc="bin/MicrosoftAjaxTimer.js"type="text/javascript"></script>
<scriptsrc="bin/BaseScripts.js"type="text/javascript"></script>
<scriptsrc="bin/Animations.js"type="text/javascript"></script>
<scriptsrc="bin/AnimationBehavior.js"type="text/javascript"></script>

2. Call Sys.Application.initialize();// somewhere within the page

3. Create component:var myAnimationComponent = $create(AjaxControlToolkit.Animation.AnimationBehavior,null,null,null, $get("MyTesButton"));

4. Set "myAnimationComponent" properties.

5. Call: Sys.Application.add_init(function() { myAnimationComponent });

Probably that's about right.

The problem I have is with the step 3. It fails in MicrosoftAjax.js script Line: 6, Character: 77054, Error: '_behaviors' is null or not an object. Further investigation reveals that the error occurs in the following line (MicrosoftAjax.debug.js, Line 6210):

var behaviors = element._behaviors;

The above line assumes that "element" object has "_behaviors" property, which may not be true. I thinkit is abug, Sys.UI.Behavior.getBehaviors() function should be used instead - see MicrosoftAjax.debug.js, line 6291.

Could anyone help?

Tomasz Jastrzebski

P.S. I know it is not meant to be used without corresponding server-side controls, but I would like to try. The reason: my hosting provider will not install AJAX and, without going into much details, I can not change hosting provider right now. So, I thought myself, may be AJAX Library can bring some value and I can still use it, instead of Prototype (http://prototype.conio.net/) based solutions.

Hi Tom,

No , its not impossible , its very much possibleWink .

Check out this link which talks about using animations from the client side .

http://blogs.msdn.com/phaniraj/archive/2007/01/20/animation-control-adding-cool-animations-in-your-application.aspx

Hope this Helps.

Thanks,

Phanatic


Hi,

Meanwhile, I came to the same conclusion, and got it working.

There is, however, one thing I do not quite understand. AnimationBehavior object, containing Animations, has to be "appended" to an existing control. Why this AnimationBehavior object can not be created programaticaly, and JSON string for the entire object/property tree has to be used instead?? Example: AnimationBehavior.OnClick property only accepts JSON string, making it impossible to programmatically an set array of Animations. Please someone prove me if I am wrong.

It looks like MS architects cut some corners, making the final product not as good (read: client-side script friendly) as it could easily be.

Thanks,

Tomasz Jastrzebski


Hi Tomasz,

The AnimationBehavior is meant to serve as a bridge between animations defined on the server and objects living on the client. All it does is play an animation (that it creates from a JSON string representing the server-side XML markup) whenever an event on the element is raised. If you're already writing JavaScript on the client, it's recommended that you just use the animations directly (check out the "static"play function on every animation) and play them whenever specific events are fired on your element.

We do this in the Toolkit too. For other controls that use animation (like CollapsiblePanel, Calendar, etc.), they just create new instances of classes derived from AjaxControlToolkit.Animation.Animation.

Thanks,
Ted


Hi Ted,

According to what you have said, the attached below example should work, but it does not, and I cannot figure out what is wrong with this picture. Could you, may be, take a look?

Thank you,

Tomasz

<%@.PageLanguage="C#" %>

<!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">

<head>

<title>Animation Demo</title>

<metaname="description"content="MS Ajax Animation Demo"/>

<metaname="author"content="Tomasz Jastrzebski"/>

</head>

<bodystyle="text-align:center;">

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

<scriptsrc="./scripts/MicrosoftAjax.debug.js"type="text/javascript"></script>

<scriptsrc="./scripts/MicrosoftAjaxWebForms.debug.js"type="text/javascript"></script>

<scriptsrc="./scripts/MicrosoftAjaxTimer.debug.js"type="text/javascript"></script>

<scriptsrc="./scripts/Animations.js"type="text/javascript"></script>

<scriptsrc="./scripts/BaseScripts.js"type="text/javascript"></script>

<div>

<inputtype="button"value="Click Me"onclick="show();return false;"/>

</div>

<divid="popup"style="display:none; cursor:hand;"title="click to hide"onclick="hide();">

<tablestyle="width:100%; height:100%;">

<tr><tdstyle="text-align:center; vertical-align:middle;">

TEST

</td></tr>

</table>

</div>

<scripttype="text/javascript">

<!--

Sys.Application.initialize();

function show() {

var animation =new AjaxControlToolkit.Animation.SequenceAnimation();

// StyleAction(target, duration, fps, attribute, value)

var action =new AjaxControlToolkit.Animation.StyleAction("popup",null,null,"display","block");

animation.add(action);

// ResizeAnimation(target, duration, fps, width, height, unit)

action =new AjaxControlToolkit.Animation.ResizeAnimation("popup", .3, 25, 300, 300,"px");

animation.add(action);

animation.play("popup",null,null);

}

function hide() {

var animation =new AjaxControlToolkit.Animation.SequenceAnimation();

var action =new AjaxControlToolkit.Animation.ResizeAnimation("popup", .3, 25, 0, 0,"px");

animation.add(action);

action =new AjaxControlToolkit.Animation.StyleAction("popup",null,null,"display","none");

animation.add(action);

animation.play("popup",null,null);

}

//-->

</script>

</form>

</body>

</html>


Hi Tomasz,

You're definitely missing some required scripts. I don't see Common.js, (the Toolkit's) Timer.js, etc.

Thanks,
Ted

Hi Ted,

Thank you for the answer. Here is another version, with all the relevant scripts I could think of.

It still does not work :(

Please help.

Tomasz

<!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">

<head>

<title>Animation Demo</title>

<metaname="description"content="MS Ajax Animation Demo"/>

<metaname="author"content="Tomasz Jastrzebski"/>

</head>

<bodystyle="text-align:center;">

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

<scriptsrc="./scripts/MicrosoftAjax.debug.js"type="text/javascript"></script>

<scriptsrc="./scripts/MicrosoftAjaxWebForms.debug.js"type="text/javascript"></script>

<scriptsrc="./scripts/MicrosoftAjaxTimer.debug.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/Common/Common.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/Compat/Timer/Timer.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/Common/Threading.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/Animation/Animations.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/ExtenderBase/BaseScripts.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/Animation/AnimationBehavior.js"type="text/javascript"></script>

<div>

<inputtype="button"value="Click Me"onclick="show();return false;"/>

</div>

<divid="popup"style="display:none; cursor:hand;"title="click to hide"onclick="hide();">

<tablestyle="width:100%; height:100%;">

<tr><tdstyle="text-align:center; vertical-align:middle;">

TEST

</td></tr>

</table>

</div>

<scripttype="text/javascript">

<!--

Sys.Application.initialize();

function show() {

var animation =new AjaxControlToolkit.Animation.SequenceAnimation();

// StyleAction(target, duration, fps, attribute, value)

var action =new AjaxControlToolkit.Animation.StyleAction("popup",null,null,"display","block");

animation.add(action);

// ResizeAnimation(target, duration, fps, width, height, unit)

action =new AjaxControlToolkit.Animation.ResizeAnimation("popup", .3, 25, 300, 300,"px");

animation.add(action);

animation.play("popup",null,null);

}

function hide() {

var animation =new AjaxControlToolkit.Animation.SequenceAnimation();

var action =new AjaxControlToolkit.Animation.ResizeAnimation("popup", .3, 25, 0, 0,"px");

animation.add(action);

action =new AjaxControlToolkit.Animation.StyleAction("popup",null,null,"display","none");

animation.add(action);

animation.play("popup",null,null);

}

//-->

</script>

</form>

</body>

</html>


Hi,

Take a look at this blogpost to see an example of using MS Ajax AnimationControls without any Server-Side Code.

Using MS Ajax Animations From the Client-Side

Hope this helps


Ach, I see, so "target" argument must be passed as reference, rather than element name.

I am attaching my revised, and working demo.

Thank you!

Tomasz

<!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">

<head>

<title>Animation Demo</title>

<metaname="description"content="MS Ajax Animation Demo"/>

<metaname="author"content="Tomasz Jastrzebski"/>

</head>

<body>

<scriptsrc="./scripts/MicrosoftAjax.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/Common/Common.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/Compat/Timer/Timer.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/Animation/Animations.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/ExtenderBase/BaseScripts.js"type="text/javascript"></script>

<inputtype="button"value="Click Me"onclick="show();return false;"/>

<br/>

<divid="popup"style="display:none; cursor:pointer; cursor:hand; border:solid 1px black;

width:50px; height:25px;"title="click to hide"onclick="hide();">

<tablestyle="width:100%; height:100%;">

<tr><tdstyle="text-align:center; vertical-align:middle;">

TEST

</td></tr>

</table>

</div>

<scripttype="text/javascript">

<!--

Sys.Application.initialize();

function show() {

var animation =new AjaxControlToolkit.Animation.SequenceAnimation();

// StyleAction(target, duration, fps, attribute, value)

var action =new AjaxControlToolkit.Animation.StyleAction($get("popup"),null,null,"display","block");

animation.add(action);

// ResizeAnimation(target, duration, fps, width, height, unit)

action =new AjaxControlToolkit.Animation.ResizeAnimation($get("popup"), .3, 25, 300, 300,"px");

animation.add(action);

animation.play("popup",null,null);

}

function hide() {

var animation =new AjaxControlToolkit.Animation.SequenceAnimation();

var action =new AjaxControlToolkit.Animation.ResizeAnimation($get("popup"), .3, 25, 50, 25,"px");

animation.add(action);

action =new AjaxControlToolkit.Animation.StyleAction($get("popup"),null,null,"display","none");

animation.add(action);

animation.play($get("popup"),null,null);

}

//-->

</script>

</body>

</html>


Hi,

Glad to know that resolved it .

Could you please mark my post as the reply ?


One more comment: it seems that this method of using AJAX scripts has a limited use.

Animation created this way is characterized by a significant delay between steps, even when duration=0. It seems that it is a bug.

I am attaching another demo. Note the the delay before the text color changes.

Also, for any reason StyleAction with "background-color" CSS property does not work.

Thank you,

Tomasz

<!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">

<head>

<title>Animation Demo</title>

<metaname="description"content="MS Ajax Animation Demo"/>

<metaname="author"content="Tomasz Jastrzebski"/>

</head>

<body>

<scriptsrc="./scripts/MicrosoftAjax.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/Common/Common.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/Compat/Timer/Timer.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/Animation/Animations.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/ExtenderBase/BaseScripts.js"type="text/javascript"></script>

<inputtype="button"value="Click Me"onclick="show();return false;"/>

<br/>

<divid="popup"style="display:none; cursor:pointer; cursor:hand; border:solid 1px black;

width:50px; height:25px;color:Red;"title="click to hide"onclick="hide();">

<tablestyle="width:100%; height:100%;">

<tr><tdstyle="text-align:center; vertical-align:middle;">

TEST

</td></tr>

</table>

</div>

<scripttype="text/javascript">

<!--

Sys.Application.initialize();

function show() {

var popup = $get("popup");

var animation =new AjaxControlToolkit.Animation.SequenceAnimation();

// StyleAction(target, duration, fps, attribute, value)

var action =new AjaxControlToolkit.Animation.StyleAction(popup,null,null,"display","block");

animation.add(action);

// ResizeAnimation(target, duration, fps, width, height, unit)

action =new AjaxControlToolkit.Animation.ResizeAnimation(popup, .3, 25, 300, 300,"px");

animation.add(action);

action =new AjaxControlToolkit.Animation.StyleAction(popup, 0, 25,"color","Green");

animation.add(action);

animation.play(popup,null,null);

}

function hide() {

var popup = $get("popup");

var animation =new AjaxControlToolkit.Animation.SequenceAnimation();

var action =new AjaxControlToolkit.Animation.StyleAction(popup, 0, 25,"color","Red");

animation.add(action);

action =new AjaxControlToolkit.Animation.ResizeAnimation(popup, .3, 25, 50, 25,"px");

animation.add(action);

action =new AjaxControlToolkit.Animation.StyleAction(popup,null,null,"display","none");

animation.add(action);

animation.play(popup,null,null);

}

//-->

</script>

</body>

</html>


If you set the Duration to Zero , MS AJAX will automatically calculate the duration of the animation( which may or may not be fast ).

To make it move faster , set the duration to be 0.01.

For the

"Also, for any reason StyleAction with "background-color" CSS property does not work."

Check the animation reference which talks about paramters to the StyleAction

http://ajax.asp.net/ajaxtoolkit/Walkthrough/AnimationReference.aspx#PropertyAnimation

"Note that for thestyle property, the key must be in a JavaScript friendly format (i.e.backgroundColor instead ofbackground-color). "

Try usingbackgroundColor instead of "background-color" and it should work


Thank you for your help! That was it. I blindly assumed that StyleAction happens immediately.

Complete, revised and working solution attached.

Tomasz

<!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">

<head>

<title>Animation Demo</title>

<metaname="description"content="MS Ajax Animation Demo"/>

<metaname="author"content="Tomasz Jastrzebski"/>

</head>

<body>

<scriptsrc="./scripts/MicrosoftAjax.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/Common/Common.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/Compat/Timer/Timer.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/Animation/Animations.js"type="text/javascript"></script>

<scriptsrc="./scripts/AjaxControlToolkit/ExtenderBase/BaseScripts.js"type="text/javascript"></script>

<inputtype="button"value="Click Me"onclick="show();return false;"/>

<br/>

<divid="popup"style="display:none; cursor:pointer; cursor:hand; border:solid 1px black;

width:50px; height:25px;background-color:#FFF;"title="click to hide"onclick="hide();">

<tablestyle="width:100%; height:100%;">

<tr><tdstyle="text-align:center; vertical-align:middle;">

TEST

</td></tr>

</table>

</div>

<scripttype="text/javascript">

<!--

Sys.Application.initialize();

function show() {

var popup = $get("popup");

// target, duration, fps, animations, iterations

var animation =new AjaxControlToolkit.Animation.SequenceAnimation();

// StyleAction(target, duration, fps, attribute, value)

var action =new AjaxControlToolkit.Animation.StyleAction(popup, 0.01,null,"display","block");

animation.add(action);

// ResizeAnimation(target, duration, fps, width, height, unit)

action =new AjaxControlToolkit.Animation.ResizeAnimation(popup, .3, 25, 300, 300,"px");

animation.add(action);

action =new AjaxControlToolkit.Animation.StyleAction(popup, 0.01,null,"backgroundColor","#DDD");

animation.add(action);

animation.play(popup,null,null);

}

function hide() {

var popup = $get("popup");

var animation =new AjaxControlToolkit.Animation.SequenceAnimation();

var action =new AjaxControlToolkit.Animation.StyleAction(popup, 0.01,null,"backgroundColor","#FFF");

animation.add(action);

action =new AjaxControlToolkit.Animation.ResizeAnimation(popup, .3, 25, 50, 25,"px");

animation.add(action);

action =new AjaxControlToolkit.Animation.StyleAction(popup, 0.01,null,"display","none");

animation.add(action);

animation.play(popup,null,null);

}

//-->

</script>

</body>

</html>


You are welcome , Glad we could helpBig Smile.

I just tried out the modified script and its really cool.

Happy Coding !!

How do I use AJAX?

The Calender Extension looked cool, so I downloaded AJAX, the framework, named ASP.NET 2.0 AJAX Extensions 1.0 (why not just Ajax Extensions?). This installed without any problems. Then I downloaded ASP.NET AJAX Control Toolkit (what's wron with Ajax Toolkit?)...

I'm running Visual Web Developer 2005 Express Edition (I just LOVE long names). One video I saw (athttp://ajax.asp.net/default.aspx) said that I had to add a reference to the DLL:s to be able to Ajaxify my website if I didn't have the full version of Visual Studio. I think I did that correct (Website/Add Reference... and then find the folder holding some DLL:s, I took all the DLL:s I could find, to be on the safe side!).

Now everything should be done to get started. No, I had to change to full permision for intranet, since my code is stored on the network (in Microsoft .NET Framework 2.0 Configuration (I've now almost run out of keys on my keyboard...)/My Computer/Adjust Zone Security/Make changes to this computer and on the Local Intranet tab change the level to Full Trust).

I still get error messages, all starting with "unable to...". Does anyone know if there is a guide/tutorial for VWD 2005 Express Edition, from downloading whatever needs to be downloaded, to using it, to ajaxify (a word used in the video I referred to above) exisiting websites, putting files where they should be put and make necessary changes to existing projects?

Thanks!

Found a good start herehttp://www.asp.net/learn/videos/view.aspx?tabid=63&id=81. This video shows that the web.config file has to be modyfied, and how it could be done. It does, however, not explain the puropse of the new elements in the file, after all, it's only a video.

After doing these changes, I got a new error: "Element 'SciptManager' is not a known element...". I managed to fix this by doing nothing! I might have restarted the application, I don't remember. That doesn't make me satisfied, though. I keep getting errors that disapear by themselves after a while. I think I still need that follow-me-tutorial...

How do I use AJAX controls when my site was not created with AJAX enabled?

My site is not originally created with AJAX Conotrol Toolkit Web Site. How do I use the TabContainer and TabPanel?

Step 1 - Add the following references to your project...

.NET: System.Web.Extensions

.NET: System.Web.Extensions.Design

PROJECT / BROWSE: AjaxControlToolkit

Step 2 - Modify your web.config (add in the bits you don't have)

<configSections><sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"><sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"><section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/><sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"><section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/><section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/><section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/></sectionGroup></sectionGroup></sectionGroup></configSections><system.web><pages><controls><add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></controls></pages><compilation debug="true"><assemblies><add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/><add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/><add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation><httpHandlers><remove verb="*" path="*.asmx"/><add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/></httpHandlers><httpModules><add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></httpModules><system.webServer><validation validateIntegratedModeConfiguration="false"/><modules><add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></modules><handlers><remove name="WebServiceHandlerFactory-Integrated"/><add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/><add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></handlers></system.webServer>

Step 3 - Top of your aspx page

<%

@.RegisterAssembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"Namespace="System.Web.UI"TagPrefix="asp" %>
<%@.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajaxToolkit" %>

I think that's about it!


Thanks! I'll give that a try. By the way, does the IIS server needs to have some kind of update for all my AJAX enabled pages to work?

As long as you've installed the ASP.NET AJAX (downloadable from this site ajax.asp.net) then you'll be fine - it has to be installed on the machine you're using as the web server as it places itself in the GAC.

How do I use Ajax

Hi,

I need to use Ajax in my project. I Added reference "Ajax.dll" to my project references.
What are the other settings I have to make?
What are the changes I have to do in Web.config file?

I'm using Asp.net 1.1 and code behind C#.

Thank you.

If you would like to apply Ajax framework to your web application,you'd better install?Visual?Studio?2005?in?your?PC?
and?download?Ajax?Beta?2,Futures?November?CTP,Ajax?control?toolkit,Microsoft?Ajax library?from?Ajax?website?- http://ajax.asp.net/default.aspx?tabid=47&subtabid=471
You can download Ajax e-learning from here - http://ajax.asp.net/default.aspx?tabid=47&subtabid=478
Try to refer to this reading to get Ajax started materials - http://ajax.asp.net/docs/

Besides,you can download Ajax professionalAjaxPro.dll,AjaxProVSTemplateandadd?reference?to?it?in?visual?
studio?2003?or?2005.Try?to?take?a?look?at?this?link?for?details?-?http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=AjaxPro

Wish the above can help you get started with Ajax.

how do I use a calendar popup in a repeater

I would really like to be able to use a calendar popup when editing items in a repeater. I would assume that handling this scenerio would be the same if you did it inside a gridview. Has anyone managed to get this to work and if so would you mind sharing some ideas? My biggest concern is that if you put the calendar control inside of the repeater you will end up with as many calendars as rows on the page which is a lot of extra html. It would be nice to be able to reuse a single calendar.

Thanks,
JustinI'd like to know how to do this as well.

It could be a popup calendar ... or it could be a hover panel that contains the calendar. What I'd like to have is a single extender instance that dynamically allows configuration of the contents of the extender (e.g. setting the date in the calendar for the particular gridrow/repeater data).

Yes - we hear you on the "dynamic configuration" point. I'm thinking through ways to have a unified method of doing that.

On this particular problem, I think what you want to do is to put an extender into the template and then have it point to a panel outside of the gridview. That way you share the popup, and the multiple extender instances don't really cost you very much.

<asp:Panel id="popup" runat="server><asp:Calendar id="cal" ...></Panel>

<asp:DataList>

<EditItemTemplate>

<asp:TextBox id="editTextBox"/>

<atlasToolkit:PopupControlExtender>

<atlasToolkit:PopupControlProperties TargetControlID='editTextBox' PopupControlID="popup"/>

</...>


Yes - we hear you on the "dynamic configuration" point. I'm thinking through ways to have a unified method of doing that.

On this particular problem, I think what you want to do is to put an extender into the template and then have it point to a panel outside of the gridview. That way you share the popup, and the multiple extender instances don't really cost you very much.

<asp:Panel id="popup" runat="server><asp:Calendar id="cal" ...></Panel>

<asp:DataList>

<EditItemTemplate>

<asp:TextBox id="editTextBox"/>

<atlasToolkit:PopupControlExtender>

<atlasToolkit:PopupControlProperties TargetControlID='editTextBox' PopupControlID="popup"/>

</...>


Hi,

Thanks for the information. The only problem that I am not ableto solve is that in the examples, the onselect event for the calendaris fed back to the server which then sets the value of the textbox. At least that is how I understood it worked. How doyou set the value of the current textbox in a grid or repeater using acalendar that is outside of the grid and that posts back to theserver? Is there a way to determine the selected textbox?

Thanks,
Justin

Justin,

Have you taken a look at the CommitScript property of the PopupControl? This allows you to run arbitrary script (including making function calls) when the PopupControl is closed. (Though it probably assumes that the PopupControl is using an UpdatePanel.)


Hi David,

I originally assumed that this is how it would be done, however what I am not clear on is how to do it. I have not been able to figure out how to get the id of the textbox and the value from the control within the context of the script that would be assigned to the CommitScript.

If you have any ideas or know of any helpful documentation it would be much appreciated.

Thanks,
Justin
I am having the same kind of problem with trying to get a popup calendar to show in an InsertTemplate for a FormView. Please see my source below.

<asp:Panel ID="Panel1" runat="server" CssClass="popupControl">
<atlas:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<center>
<asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#999999" CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" Width="160px" OnSelectionChanged="Calendar1_SelectionChanged" Visible="False">
<SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />
<TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" />
<SelectorStyle BackColor="#CCCCCC" />
<WeekendDayStyle BackColor="#FFFFCC" />
<OtherMonthDayStyle ForeColor="Gray" />
<NextPrevStyle VerticalAlign="Bottom" />
<DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" />
<TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" />
</asp:Calendar>
</center
</ContentTemplate>
</atlas:UpdatePanel>
</asp:Panel
<asp:FormView ID="fvInfo" runat="server" DataKeyNames="id" DataSourceID="ds1"
DefaultMode="Insert">
<InsertItemTemplate>
Date of Birth:
<asp:TextBox ID="date_of_birthTextBox" runat="server" Text='<%# Bind("date_of_birth") %>'></asp:TextBox><br /
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="Insert"></asp:LinkButton
<atlasToolkit:PopupControlExtender ID="PopupControlExtender1" runat="server">
<atlasToolkit:PopupControlProperties TargetControlID="date_of_birthTextBox" PopupControlID="Panel1" Position="Bottom" />
</atlasToolkit:PopupControlExtender>

</InsertItemTemplate>
</asp:FormView
/// <summary>
/// Handler for calendar changes
/// </summary>
/// <param name="sender">source</param>
/// <param name="e">arguments</param>
protected void Calendar1_SelectionChanged( object sender, EventArgs e )
{
// Popup result is the selected date
int iIndex = 0, iTxtIndex = -1;
AtlasControlToolkit.PopupControlExtender pExt = null;

foreach ( Control pCntrl in fvInfo.Controls )
{
if ( pCntrl.ID == "PopupControlExtender1" )
pExt = (AtlasControlToolkit.PopupControlExtender) pCntrl;

if ( pCntrl.ID == "date_of_birthTextBox" )
iTxtIndex = iIndex;

if ( (iTxtIndex >= 0) && (pExt != null) )
break;

iIndex++;
}
if((pExt != null) && (iTxtIndex >= 0))
pExt.Commit( fvInfo.Controls[iIndex], Calendar1.SelectedDate.ToShortDateString() );
}
This is where things are getting very tricky ... I may have worked my way into a solution.

BE AWARE OF THE FOLLOWING: The extenders are using the ClientID. If you have a simple form and no master ... ID == ClientID for top level controls.

If you are using FormView/GridView ... ClientID != ID.

If you are using Master ... ClientID != ID.

If you are using dynamic (non-markup driven template, i.e. custom ITemplate implementations) ... then you need to do the work yourself to ensure that you are providing the correct ClientID.

This is why I believe that I've seen a variety of problems raised ... folks are cut & pasting markup from a simple page into a much more complicated page and not accounting for this. And/Or the toolkit as of April CTP is not accounting for this.

While this isn't a solution ... it is what I've been learning the hard way ... hope it helps.

Yes - the extenders highlight ASP.NET naming semantics in very focused way. Most other ASP.NET things don't reference each other directly so you're able to avoid running into this.

The Toolkit can't do a ton to help you here. But one of the great things about being alpha-type code is that we can try things.

So in the refresh release (today or tomorrow probably), we've added an event to the extender that you can handle to help with this. Basically if we fail to find a control based on ID, we'll raise the event, hand you the ID, and give you a chance to find it. It might be a super helpful thing, it might just be a lot of rope, we'll see.


I have worked with various Microsoft development environments for anumber years now. This is quickly becoming the most fun becauseof the interaction with the guys who are building the code. Ihave to say thanks for the openness with these controls and the speedthat new items are released. I know that I am looking forward tothe next drop. I'll be playing with the events as soon as yourelease.

Thanks for the help and for listening.
Justin

Wow - thanks for saying that. That's really the goal, and just hearing that it's working makes it all worth it.

We're having a blast too, by the way. :)

How do I update text in a panel using ajax and a timer?

This is a pretty basic question, I just need to update a textbox every few minutes without using a postback. The text is pulled from a sql query. Is there a example for how to do this somewhere? (simialar to how gmail updates, etc...)

Take a look at this: http://encosia.com/index.php/2007/07/25/display-data-updates-in-real-time-with-ajax/

If you're only updating a simple text label, you could skip the UpdatePanel in my example andupdate that text on the client side, using a web method.

A combination of those two examples should give you what you're after.


Thanks for providing links.

How do I update a panel on page load?

I am sure it's something dumb.

Using the december preview. How do I update a panel on page load without a timer or a button? Obviously I want this done after the page loads and renders.

Thx
dB.

You can call the Update method on UpdatePanel.

HOW DO I update a control from outside the updatepanel

i have an update panel with 4 panels. when the user select panel 2 i need a control outside the updatepanel to become visible. i can not put the hidden div inside the updatepanel because the contents of the div will not work. how do update the div control from panel 2?

To make visible the control outside updatepanel is not possible upto my knowledge. definitely you have to include that control into another udpatepanel or include it with your 1st updatepanel.


Hi CurlyFro,

Here is the sample to indicate how to show a hidden div, which is out of a UpdatePanel, from a panel click event or a button click event in UpdatePanel. Hope it helps.

<%@. 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) { } protected void Button2_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "showDiv();", true); }</script><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title>Untitled Page</title> <script language="javascript"> function showDiv(){ document.all.myDiv1.style.display=''; //do something here to update the hidden div } </script></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate><%=DateTime.Now.ToString()%> <asp:Panel ID="Panel1" runat="server" Height="50px" Width="200px" onclick="showDiv()" BorderColor="AliceBlue" BorderWidth="1px"> <input id="Button1" type="button" value="button" /> </asp:Panel> <br/> <asp:Panel ID="Panel2" runat="server" Height="50px" Width="200px" BorderColor="Black" BorderWidth="1px" > <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="ServerSideButton" /> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> <div id="myDiv1" style="width: 200px; height: 100px; display: none"> This is the hidden div </div> </form></body></html>

This sample contains two ways (server side and client side methods) to show the hidden div.

If i misunderstood you, please let me know!


i'm creating a registration form. panel1 is my license, panel2 is the registration form, panel3 is my confirmation. on panel2 i have form hints for specific textboxes. how do i get the form hints to be hidden then shown on panel2?

Since you have many steps, I suggesting to wrap these in an Asp.net Wizard Control then put the Wizard Control in an UpdatePanel.


Hi CurlyFro,

Would you please share your source code here ? It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

Hi CurlyFro,

Has your problem been resolved yet?

How do I UnitTest My Atlas component

Hi,

Can anyone guide me how I can unit test my atlas component. Here is the scenario
I have existing app which is using javascript ...now i was thinking about removing it
and implement atlas functionality. However this gives me opportunity to write test
cases. Can someone tell me if MSTS has inbuilt functionality for this or which other
way i can test my component built in atlas. Will Nunitasp or Nunit work?

Thank you

VSTS does not have built-in support for JavaScript. Neither does NUnit. You might be able to use NUnitAsp, but I would recommend JsUnit:http://www.edwardh.com/jsunit/

-Mike

How do I trigger an UpdatePanel from the ItemCommand event of a data-bound Accordion?

Greetings, clever ASP.NET AJAX users.

I have a data-bound Accordion with a Button in each header. Cliking the button changes a label inside an UpdatePanel. But I don't want a full postback when the Button is clicked. I just want the UpdatePanel itself updated.

I have tried registering the ItemCommand event of the Accordion as a trigger, but I get this error message, which I don't understand:

Control with ID 'accAccordion' being registered through RegisterAsyncPostBackControl or RegisterPostBackControl must implement either INamingContainer, IPostBackDataHandler, or IPostBackEventHandler.

Here is my code:

 <asp:UpdatePanel ID="upUpdatePanel" runat="server" ChildrenAsTriggers="true" > <ContentTemplate> <div style="border:1px solid black;"> Name: <asp:Label ID="lblName" runat="server" /><br /> <asp:Button ID="btnChange" runat="server" OnClick="btnChange_Click" Text="Inside Update Panel"/> </div> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="accAccordion" EventName="ItemCommand" /> </Triggers> </asp:UpdatePanel> <br /> <ajaxtoolkit:Accordion ID="accAccordion" runat="server" RequireOpenedPane="false" OnItemDataBound="accAccordion_ItemDataBound" OnItemCommand="accAccordion_ItemCommand"> <HeaderTemplate> header: <asp:Button ID="btnChange" runat="server" CommandArgument="Inside Update Panel" /> </HeaderTemplate> <ContentTemplate> content:<br /> </ContentTemplate> </ajaxtoolkit:Accordion>
public partialclass _Test : System.Web.UI.Page{protected string[] aNames = {"foo","bar","baz" };protected void Page_Load(object sender, EventArgs e) {this.accAccordion.DataSource =this.aNames;this.accAccordion.DataBind(); }protected void btnChange_Click(Object sender, EventArgs e) {this.lblName.Text =this.btnChange.Text; }protected void accAccordion_ItemDataBound(Object sender, AjaxControlToolkit.AccordionItemEventArgs e) {if (e.AccordionItem.ItemType == AjaxControlToolkit.AccordionItemType.Header) { Button btnChange = (Button)e.AccordionItem.FindControl("btnChange"); btnChange.Text = e.AccordionItem.DataItem.ToString(); btnChange.CommandArgument = btnChange.Text; } }protected void accAccordion_ItemCommand(Object sender, CommandEventArgs e) {this.lblName.Text = e.CommandArgument.ToString(); }}

Obviously if I remove the trigger the error goes away, but then I don't get partial page rendering. I tried adding code to the ItemDataBound event of the Accordion to register the Button with the ScriptManager as an AsyncCallBack or whatever it is, and then added code to the ItemCommand event to call the Update() method of the UpdatePanel, but that doesn't work either -- I still get a full postback.

Any ideas?

If it's not feasible to trap the ItemCommand event of the Accordion or the Click event of the Button, is there a more exotic solution that would let me trigger the UpdatePanel from client script? I would need to be able to somehow pass the CommandArgument from the specific button that was clicked...


FYI, I worked around this problem using the approach described here:http://weblogs.asp.net/rajbk/archive/2007/01/21/refresh-updatepanel-via-javascript.aspx

I used SuppressHeaderPostBasks="true" on the Accordion, then for each Button in the Accordion Pane's header, I used the OnClientClick property to set the value of a hidden input element inside the update panel, then call the __doPostBack method pointing at that element. In the codebehind, I trapped the Change event of the hidden input element and did my processing.


I have an updatepanel inside an Accordion and I think you might have the solution for my problem, but I don't understand you process.

I would be grateful if you could help me.

Here's my code;

codebehind

protectedvoid Page_Init(object sender,EventArgs e)

{

Accordion1.FindControl("nothing");

LinkButton UserLink = Accordion1.FindControl("UserLink")asLinkButton;

ScriptManager.GetCurrent(this.Page).RegisterAsyncPostBackControl(UserLink);

//Creates a new async trigger

AsyncPostBackTrigger trigger =newAsyncPostBackTrigger();

//Sets the control that will trigger a post-back on the UpdatePanel

trigger.ControlID ="UserLink";

//Sets the event name of the control

trigger.EventName ="Click";

//Adds the trigger to the UpdatePanels' triggers collection

UpdatePanelUser.Triggers.Add(trigger);

}

protectedvoid Page_Load(object sender,EventArgs e)

{

}

protectedvoid UserLink_Click(object sender,EventArgs e)

{

//UpdatePanel getUserPanel = UserPanel.FindControl("UpdatePanelUser") as UpdatePanel;

//ScriptManager.GetCurrent(this.Page).RegisterAsyncPostBackControl(getUserPanel);

String userPanelPath ="~/CMS/_admin/_components/CMS_controls/admin_controls/UserPanel.ascx";Control userPanel = Page.LoadControl(userPanelPath);

PanelUser.Controls.Add(userPanel);

UpdatePanelUser.Update();

}

aspx

<ajaxToolkit:AccordionID="Accordion1"runat="server"HeaderSelectedCssClass="AdminPanelHeaderSelected"RequireOpenedPane="false"SuppressHeaderPostbacks="true"SelectedIndex="0"HeaderCssClass="AdminPanelHeader"ContentCssClass="AdminPanelContent"FadeTransitions="true"FramesPerSecond="40"TransitionDuration="250"AutoSize="none">

<Panes>

<ajaxToolkit:AccordionPanerunat="server"ID="Home">

<Header>

<ahref=""onclick="return false;">Home</a>

</Header>

<Content>

</Content>

</ajaxToolkit:AccordionPane>

<ajaxToolkit:AccordionPanerunat="server"ID="UserPanel">

<Header>

<asp:LinkButtonID="UserLink"runat="server"OnClick="UserLink_Click">User panel</asp:LinkButton>

</Header>

<Content>

<asp:UpdatePanelID="UpdatePanelUser"runat="server"UpdateMode="Conditional">

<ContentTemplate>

<asp:PanelID="PanelUser"runat="server">

</asp:Panel>

</ContentTemplate>

</asp:UpdatePanel>

</Content>

</ajaxToolkit:AccordionPane>

<ajaxToolkit:AccordionPanerunat="server"ID="STATS">

<Header>

<ahref=""onclick="return false;">Statistics</a>

</Header>

<Content>

</Content>

</ajaxToolkit:AccordionPane>

<ajaxToolkit:AccordionPanerunat="server"ID="GroupEmails">

<Header>

<ahref=""onclick="return false;">Group Email</a>

</Header>

<Content>

</Content>

</ajaxToolkit:AccordionPane>

<ajaxToolkit:AccordionPanerunat="server"ID="Errors">

<Header>

<ahref=""onclick="return false;">Error reporting</a>

</Header>

<Content>

</Content>

</ajaxToolkit:AccordionPane>

</Panes>

</ajaxToolkit:Accordion>

Thanks.

How do I trigger a script to run when a PopupControl gets hidden?

To put it another way: How do I trigger a script to run when a PopupControl gets hidden?Smile

Seeing as the control toolkit handles all the event trapping and so on, I don't know what event to trap and how. Anyone know?

Hi,

the ModalPopup exposes an OnCancelScript property. You can set this property to the script that will be executed when the popup is dismissed.


Hmm ... if I was using a ModalPopup that would be a great tip, but I'm using a normal PopupControl. I've found a dirty trick - the animation property allows a javascript routine to be called when the popup closes. Initially I tried using a javascript _doPostBack to run a server-side routine, but I couldn't get that to work, so I did the whole thing client side instead. It may not be the prettiest way to do it, but hey, it works.

How do I tell which version of atlas Im running?

Hi, Im running an old version of Atlas, and I need to upgrade it to I guess the latest ajax.net right?

There are instructions on hompage for upgrading from "ctp" to "rc" or from "beta 2" to "rc". How do I tell what version I have and what version do I want to upgrade to?

Also, with this upgrade, with that also upgrade my atlas control toolkit?

Thanks, sorry so noobish, I just want to make sure i upgrade this right the first time, thanks.

Joeybagadonutz:

Hi, Im running an old version of Atlas, and I need to upgrade it to I guess the latest ajax.net right?

There are instructions on hompage for upgrading from "ctp" to "rc" or from "beta 2" to "rc". How do I tell what version I have and what version do I want to upgrade to?

Also, with this upgrade, with that also upgrade my atlas control toolkit?

Thanks, sorry so noobish, I just want to make sure i upgrade this right the first time, thanks.

The web.config file should be upgraded automatically when installing the new version. The old controls on toolkit need to be remove manually and the new controls need to be added manually. Hope that helps.


and will my old controls still work?

If I completely backup my existing project before upgrade, and this upgrade breaks my projects, can I just reinstall the old version again to restore?


Joeybagadonutz:

and will my old controls still work?

If I completely backup my existing project before upgrade, and this upgrade breaks my projects, can I just reinstall the old version again to restore?

I never had any problem with its upgrade so I wouldn't know if you can downgrade it or not. Your old controls need to be removed. They will not work due to the changes in web.config file.

How do I start using AJAX controls on an existing project?

I went through the video tutorial where it had me open a template project, then add a confirmbuttonextender which worked very well. I noticed when i opened the template on the aspx page by following the videos instructions, it already contained a scriptmanager. On my existing poject I do the same steps to setup the button control, only this time i manually added a scriptmanager, but my button does nothing. Is there something i have to do to my project to enable it to Use the AJAX controls or something I have to do to the scriptmanager?

jwkeenan:

I went through the video tutorial where it had me open a template project, then add a confirmbuttonextender which worked very well. I noticed when i opened the template on the aspx page by following the videos instructions, it already contained a scriptmanager. On my existing poject I do the same steps to setup the button control, only this time i manually added a scriptmanager, but my button does nothing. Is there something i have to do to my project to enable it to Use the AJAX controls or something I have to do to the scriptmanager?

also there is a confiuration.

the best way to start using AJAX controls on an existing project . open an ASP.NET AJAX-Enabled Web Site . then add the pages in the existing project.

Regards.


ok i opened a new asp.net ajax web enabled site and added all the items form my other project, but the control still does nothing. Any other ideas i can try?


Hi, I try this way several times. I had several project and do this way.

note: don't add the web.config file from the exist project.

is ther an error appear to you?


It works! I was reloading my old web config file. Thanks for your help.


I started by...

Downloaded the ASP.NET AJAX Control Toolkit and load it's sample website into an instance of vs2005. You can run the sample website in debug mode and copy/paste desired code segments directly into your application. After you get the hang of specific controls then you can pick them directly from your AJAX Control Toolkit tab on the tools browser. This process will also helps in understanding the usage of the update panel.

PS - check out my schools site at:www.jeromessite.com.

If you like the way it works the let me know and I will direct you to the source code.

Thanks,

Jerome

How do I speed up or slow down the collapsing or expanding of an CollapsiblePanelExtender

How would I go about speeding up or slowing down the collapsing or expanding of a CollapsiblePanelExtender.

that i guess would not be possible becoz the expanding mainly depends on how fast the content come from the server,basically depending on the internet conection.the next(after the first) expand could be faster if caching of the content is done.

How do I show postback search results on a Modal Popup?

My goal is to show the serach results in a grid view on a model popup after the user enters the search criteria on a page and presses the search button. The OnClick event handler needs to collect the search criteria, get the dataset after querying the database and bind the data to the gridview before displaying the modal popup.

My problem is that the search button's id can't be assigned to the TargetControlID of the ModalPopupProperties as it will not let the OnClick event be fired and process the postback.

Please suggest the solution/workaround.

Thanks much

Display the ModalPopup via script instead?

David,

Do you have an example or a sample of the script that I can take a look at?

The other option would be to dynamically create the popup, after I process my search funcationility. But the question is, how do I invoke the display of the popup after associating the TargetID of the search button to the dynamically created ModelPopup?

Thanks for looking into it.

Vijay


I believe the following post outlines how to display the ModalPopup with script:http://forums.asp.net/thread/1280980.aspx

How do I set off a process and display UpdatePanel on page load

I think this should be a simple task: I have a page that does some lengthy processing and I am using an update panel to show the user that something is happening. Currently, I have to load the page and the user has to press a buttong to start processing. Now, for me, this is a pointless step.. I want the page to kick off the server processing on page load and then display a page with the UpdatePanel which is then updated when the process is complete.

What is the best way to do this?.. Any suggestions?

:)

let me try this idea. once processing starts, you had the actual update panel, and show the update progress control, which gives the idea that processing is going on another page, then show the panel back again.

just a suggestion, since Atlas allows us to work with different parts of the page, somewhat like in windows forms.

a trial.

Regards,
formationusa


repost

Hide instead of had
sorry for the mistake, i have to check my spelling more often.

let me try this idea. once processing starts, you hide the actual update panel, and show the update progress control, which gives the idea that processing is going on another page, then show the panel back again.

just a suggestion, since Atlas allows us to work with different parts of the page, somewhat like in windows forms.

a trial.

Regards,
formationusa

How do I set focus on CascadingDropDown?

I'm trying to set focus on a Dropdownlist that's being populated by the nice CascadingDropDown tool. But I can't. Everything else works great, The forms retreive, insert, update without page postbacks via updatepanel. The CascadingDropDown tools work well with the dropdownlists and it all populates dependent on each other and without page postbacks. BUT I can't seem to set the focus to the dropdownlist that's being populated by the CascadingDropDown tool..

I've got the scriptmanager on the masterpage and the Dropdownlist I want to set focus upon is in a formview. I want it to set focus on the control when the form is changed to a insert or edit mode.

So my code behind is like this:

protectedvoid formView1_ModeChanged(object sender,EventArgs e)

{

if (formView1.CurrentMode ==FormViewMode.Insert || formView1.CurrentMode ==FormViewMode.Edit)

{

Master.ScriptManager1.SetFocus(formView1.FindControl("ddl_iWantFocused"));

}

}

Works great for selecting any other control in the form, but not the one populated with the CascadingDropDown.

Any help on how to set focus on this?

Let me revise that. I can SetFocus on other DropDownLists that don't use the CascadingDropDownList extender, but haven't been able to SetFocus on a Textbox.

How do I send email using ajax modal popup extender

I have a panel that sends an email message. I wish to use an ajax modal popup extender to display this panel when a user clicks a "Contact Us" link button. I get an error message when I try to run the application. My code follows.Thank you for any suggestions.

<body>
<form id="form1" runat="server">
<ajaxToolkit:ToolkitScriptManager ID="ScriptManager1" runat="server" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID ="ContactUsLinkButton"
PopupControlID ="EmailPopupPanel"
OkControlID="OKButton"
CancelControlID="CancelButton"
DropShadow="true"
BackgroundCssClass ="modalBackground" />
<asp:LinkButton ID="ContactUsLinkButton" runat="server">Contact Us</asp:LinkButton>


<div >
<asp:Panel ID="EmailPopupPanel" runat="server" CssClass ="popupEmail" Width="325px" Style="display: none" >
<asp:Label ID="TitleLabel" runat="server" BackColor="#FFFFC0"
Font-Bold="True" Font-Size="Medium" ForeColor="SteelBlue" Text="Contact D`Stroke Tennis"
Width="300px"></asp:Label>
<br />
<asp:Label ID="InfoLabel" runat="server" Font-Bold="True" Font-Size="Medium" ForeColor="Red"></asp:Label>
<br />
<br />
<asp:Button ID="OKButton" runat="server" BackColor="#FFFFC0" Font-Bold="True" ForeColor="DarkRed"
Text="OK" Visible="False" /><br />
<span style="color: #990000"><strong><asp:Label ID="FromLabel" runat="server" Text="From:"></asp:Label></strong> </span>
<asp:TextBox ID="FromTextBox" runat="server" Width="250px" ForeColor="DarkRed"></asp:TextBox>
<br />
<br />
<asp:Label ID="ToLabel" runat="server" Text="To: admin@dotnet.itags.org.dstroketennis.com" Width="300px" BackColor="#FFFFC0" Font-Bold="True" ForeColor="DarkRed"></asp:Label>
<br />
<br />
<span style="color: #990000"><strong><asp:Label ID="SubjectLabel" runat="server"
Text="Subject:"></asp:Label></strong></span>
<asp:TextBox ID="SubjectTextBox" runat="server" Width="240px"></asp:TextBox><br />
<br />
<span style="color: #990000"><strong>
<asp:Label ID="MessageLabel" runat="server"
Text="Message:"></asp:Label></strong></span><br />
<asp:TextBox ID="MessageTextBox" runat="server" Height="150px" TextMode="MultiLine"
Width="300px" ForeColor="DarkRed"></asp:TextBox><br />
<asp:Button ID="SendEmailButton" runat="server" BackColor="#FFFFC0" BorderColor="DarkRed"
BorderStyle="Solid" Font-Bold="True" ForeColor="DarkRed" Text="Send Email" Width="173px" />
<br />
<asp:Button ID="CancelButton" runat="server" BackColor="#FFFFC0" BorderColor="DarkRed"
BorderStyle="Solid" Font-Bold="True" ForeColor="SteelBlue" Text="Cancel Email" Width="173px" /></asp:Panel>
</div>
</form>
</body>

Tags:ajax, ie 7, Microsoft JScript runtime error: Sys.ArgumentNullException: Value cannot be null. Parameter name: element

When do you get the Sys.ArgumentNullException error? Also, try getting rid of the Style="display: none" on the Panel...

-Damien


I get the error when the page loads.


I Got rid of the Style "display : none" and I get the same error on page load.


See if this related post helps:http://forums.asp.net/p/1107533/1700376.aspx

-Damien


I also ran across this:http://www.spthorn.com/blog.php?post=28&PHPSESSID=c42ace58bb0f0d24ab3d9d2eef948c4a

-Damien


Thanks Damien. The asp buttons weren't plugged into anything I am guessing. My new challenge with this now is to have the email send, and display a message that the send was a success before leaving modal state.

At least this one issue is handled.