Showing posts with label dropdownlist. Show all posts
Showing posts with label dropdownlist. Show all posts

Wednesday, March 28, 2012

Calling a Script in UpdatePanel

I am having a problem calling javascript from within an update panel.

Here is what I have set up:

When you select a given index on a dropdownlist, the updatepanel is populated with a custom control I built that loads a wysiwyg editor (widgeditor). The editor requires a javascript call to initialize, but the script (which is registered within the UpdatePanel's control collection), does not fire. In fact, no scripts will fire...

I tried using RegisterStartupScript, RegisterLoadScript, and adding a script via a ScriptManagerProxy.

Any thoughts? I feel there must be a way to accomplish this.

Thanks!

Ben

hehe, from the department of answering my own questions:

I found my big lead here - using the ScriptManager.RegisterScriptBlock:

http://forums.asp.net/2/1550428/ShowThread.aspx

...and updated it using the ScriptManager.RegisterStartupScript ... which made everything work lovely.

I figured there was a good answer to this problem.

Ben

Saturday, March 24, 2012

Call a client JavaScript function after each and every AJAX callback

Hi,

I have a DropDownList, which is enabled or disabled depending on the state of a CheckBox. I am doing this in JavaScript. I have a function which checks the state of the CheckBox, and sets the DropDownList as either enabled or disabled accordingly. I have attached a call to this function to the 'OnClick' attribute of the CheckBox so it gets called each time the CheckBox is used.

All of this is in an UpdatePanel, along with some other functionality which is not directly related. The problem I am having is that each time there is a Postback to the server (or rather I should say a Callback, as we are in an UpdatePanel), the DropDownList is changed to enabled, even if it was disabled before the Callback.

I thought an easy way to solve this would be to call my 'Disable the DropDownList according to the state of the CheckBox' function after each Callback.

So... how can I set my page to call a JavaScript function after each Callback?

Thanks...

Hi,

I'm using this for that task:

function pageLoad( )
{
Sys.WebForms.PageRequestManager.getInstance( ).add_pageLoaded( PageLoadedHandler );
}

function PageLoadedHandler( sender, args )
{
// your code
}

Check ASP.NET AJAX Client Life-Cycle Events for what is pageLoad, also seepageLoaded Event from the same page.



Thanks very much - that is exactly what I needed. I think I need to get down to it and start exploring the whole Sys.WebForms namespace properly.

Thanks again for your help - I'm very grateful.

Wednesday, March 21, 2012

CalendarExtender Pops up below DropDownList - need help

Hi, I've used CalendarExtender with a TextBox. In the next row I had a dropdownList. Now, when I click the imagebutton, the Calender pops-up below the DropDownList.

Can any one help me with this?

Hi,

Please refer to this post: http://forums.asp.net/p/834115/834115.aspx#834115