473,698 Members | 2,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

update panels and javascript?

We have an update panel that has a gridview with checkboxes and other
items in each row. We went to the RowCreated event in the codebehind,
to set an attribute on a checkbox in each row, to execute a particular
javascript function (client-side). THis is supposed to work. I've
done it hundreds of times otherwise, but never in an update panel
(until now).
It doesn't work. I put an alert in the top of my javascript function,
and it never is executed. I made sure that script debugging was
enabled (or rather, not disabled). I get no error either on setting
the attribute, or when I click the check boxes on any of the rows in
the gridview.

So, how do people set up controls within an update panel, to execute
client-side code?

Oct 16 '07 #1
5 3440
In your browser View Source and see if you are getting your JavaScript
right.
This is how I do it and most of the time my View Source tells me what is
wrong in my JavaScript.

Make sure your ClientID(s) are correct.
There might be syntax errors in your JavaScript

Also set you Browser to always report JavaScript errors, you will be
surprised how many web pages out there with JavaScript errors that
programmers fail to see because there browser set up to NOT show errors.

"HockeyFan" <le**********@g mail.comwrote in message
news:11******** *************@q 3g2000prf.googl egroups.com...
We have an update panel that has a gridview with checkboxes and other
items in each row. We went to the RowCreated event in the codebehind,
to set an attribute on a checkbox in each row, to execute a particular
javascript function (client-side). THis is supposed to work. I've
done it hundreds of times otherwise, but never in an update panel
(until now).
It doesn't work. I put an alert in the top of my javascript function,
and it never is executed. I made sure that script debugging was
enabled (or rather, not disabled). I get no error either on setting
the attribute, or when I click the check boxes on any of the rows in
the gridview.

So, how do people set up controls within an update panel, to execute
client-side code?

Oct 16 '07 #2
the update panel does not support client events tied to the control via
html. this is becuase the browser doesnot support it: ex:

div.innerHTML = "<button onclick='doClic k()'>click me</button>";

the onclick event handler will not be hooker, nor will inline script work:
div.innerHTML = "<script>alert( 'hi')</script>";

you will need to attach the onclick event via javascript the updatepanel
will run afterwards. using

ScriptManager.G etCurrent(Page) .RegisterClient ScriptBlock(Pag e,this.GetType( ),"key1",
"$get('mycontro lid').onclick=d oclick;",
true);

in this case, the script is sent down and the updatepanel code will do
an eval() of it.

of course in your case, you need to add one for for each row. the
databind would be handy for this, or your client script could walk the
dom and add the events.

-- bruce (sqlwork.com)


HockeyFan wrote:
We have an update panel that has a gridview with checkboxes and other
items in each row. We went to the RowCreated event in the codebehind,
to set an attribute on a checkbox in each row, to execute a particular
javascript function (client-side). THis is supposed to work. I've
done it hundreds of times otherwise, but never in an update panel
(until now).
It doesn't work. I put an alert in the top of my javascript function,
and it never is executed. I made sure that script debugging was
enabled (or rather, not disabled). I get no error either on setting
the attribute, or when I click the check boxes on any of the rows in
the gridview.

So, how do people set up controls within an update panel, to execute
client-side code?
Oct 16 '07 #3
Bruce,

good job,

can you use
ClientScript.Re gisterClientScr iptBlock( etc......)

what does ScriptManager.G etCurrent(Page) . mean?

Thank u

"bruce barker" <no****@nospam. comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
the update panel does not support client events tied to the control via
html. this is becuase the browser doesnot support it: ex:

div.innerHTML = "<button onclick='doClic k()'>click me</button>";

the onclick event handler will not be hooker, nor will inline script work:
div.innerHTML = "<script>alert( 'hi')</script>";

you will need to attach the onclick event via javascript the updatepanel
will run afterwards. using

ScriptManager.G etCurrent(Page) .RegisterClient ScriptBlock(Pag e,this.GetType( ),"key1",
"$get('mycontro lid').onclick=d oclick;",
true);

in this case, the script is sent down and the updatepanel code will do an
eval() of it.

of course in your case, you need to add one for for each row. the databind
would be handy for this, or your client script could walk the dom and add
the events.

-- bruce (sqlwork.com)


HockeyFan wrote:
>We have an update panel that has a gridview with checkboxes and other
items in each row. We went to the RowCreated event in the codebehind,
to set an attribute on a checkbox in each row, to execute a particular
javascript function (client-side). THis is supposed to work. I've
done it hundreds of times otherwise, but never in an update panel
(until now).
It doesn't work. I put an alert in the top of my javascript function,
and it never is executed. I made sure that script debugging was
enabled (or rather, not disabled). I get no error either on setting
the attribute, or when I click the check boxes on any of the rows in
the gridview.

So, how do people set up controls within an update panel, to execute
client-side code?

Oct 17 '07 #4
just to confuse things there are two client managers.

Page.ClientScri pt is the builtin one for asp.net

ScriptManager is the new ajax script manager used to output script for
the ajax controls and the update panel. scriptmanager is an ajax control
you place on the page to make it ajax enabled.

ScriptManger.Ge tCurrent(Page)

searches the page for the actual scriptmanger control placed on the
page, so you don't need the name. handy inside of ajax aware control you
write.

script registered with the ClientScript, will not work with an async
postback via the update panel, you must use the ajax control. it actualy
includes the response payload, and client script on the page does an
eval of it.

-- bruce (sqlwork.com)

IfThenElse wrote:
Bruce,

good job,

can you use
ClientScript.Re gisterClientScr iptBlock( etc......)

what does ScriptManager.G etCurrent(Page) . mean?

Thank u

"bruce barker" <no****@nospam. comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>the update panel does not support client events tied to the control via
html. this is becuase the browser doesnot support it: ex:

div.innerHTM L = "<button onclick='doClic k()'>click me</button>";

the onclick event handler will not be hooker, nor will inline script work:
div.innerHTM L = "<script>alert( 'hi')</script>";

you will need to attach the onclick event via javascript the updatepanel
will run afterwards. using

ScriptManager. GetCurrent(Page ).RegisterClien tScriptBlock(Pa ge,this.GetType (),"key1",
"$get('mycontr olid').onclick= doclick;",
true);

in this case, the script is sent down and the updatepanel code will do an
eval() of it.

of course in your case, you need to add one for for each row. the databind
would be handy for this, or your client script could walk the dom and add
the events.

-- bruce (sqlwork.com)


HockeyFan wrote:
>>We have an update panel that has a gridview with checkboxes and other
items in each row. We went to the RowCreated event in the codebehind,
to set an attribute on a checkbox in each row, to execute a particular
javascript function (client-side). THis is supposed to work. I've
done it hundreds of times otherwise, but never in an update panel
(until now).
It doesn't work. I put an alert in the top of my javascript function,
and it never is executed. I made sure that script debugging was
enabled (or rather, not disabled). I get no error either on setting
the attribute, or when I click the check boxes on any of the rows in
the gridview.

So, how do people set up controls within an update panel, to execute
client-side code?

Oct 17 '07 #5
Bruce,

Excellent, Thank you for taking the time to explain,

well done.
"bruce barker" <no****@nospam. comwrote in message
news:OR******** ******@TK2MSFTN GP05.phx.gbl...
just to confuse things there are two client managers.

Page.ClientScri pt is the builtin one for asp.net

ScriptManager is the new ajax script manager used to output script for the
ajax controls and the update panel. scriptmanager is an ajax control you
place on the page to make it ajax enabled.

ScriptManger.Ge tCurrent(Page)

searches the page for the actual scriptmanger control placed on the page,
so you don't need the name. handy inside of ajax aware control you write.

script registered with the ClientScript, will not work with an async
postback via the update panel, you must use the ajax control. it actualy
includes the response payload, and client script on the page does an eval
of it.

-- bruce (sqlwork.com)

IfThenElse wrote:
>Bruce,

good job,

can you use
ClientScript.R egisterClientSc riptBlock( etc......)

what does ScriptManager.G etCurrent(Page) . mean?

Thank u

"bruce barker" <no****@nospam. comwrote in message
news:%2******* *********@TK2MS FTNGP04.phx.gbl ...
>>the update panel does not support client events tied to the control via
html. this is becuase the browser doesnot support it: ex:

div.innerHT ML = "<button onclick='doClic k()'>click me</button>";

the onclick event handler will not be hooker, nor will inline script
work:
div.innerHT ML = "<script>alert( 'hi')</script>";

you will need to attach the onclick event via javascript the updatepanel
will run afterwards. using

ScriptManager .GetCurrent(Pag e).RegisterClie ntScriptBlock(P age,this.GetTyp e(),"key1",
"$get('mycont rolid').onclick =doclick;",
true);

in this case, the script is sent down and the updatepanel code will do
an eval() of it.

of course in your case, you need to add one for for each row. the
databind would be handy for this, or your client script could walk the
dom and add the events.

-- bruce (sqlwork.com)


HockeyFan wrote:
We have an update panel that has a gridview with checkboxes and other
items in each row. We went to the RowCreated event in the codebehind,
to set an attribute on a checkbox in each row, to execute a particular
javascript function (client-side). THis is supposed to work. I've
done it hundreds of times otherwise, but never in an update panel
(until now).
It doesn't work. I put an alert in the top of my javascript function,
and it never is executed. I made sure that script debugging was
enabled (or rather, not disabled). I get no error either on setting
the attribute, or when I click the check boxes on any of the rows in
the gridview.

So, how do people set up controls within an update panel, to execute
client-side code?
Oct 17 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7122
by: Miguel Dias Moura | last post by:
Hello, i have 5 panels in an ASP.net / VB page. The panel 1 is visible the other 4 are NOT visible. I also have 5 images: image 1, image 2, ..., image5. When i click one of the images, image N, the panel N becomes visible and all the other invisible.
1
5710
by: komatouch09 | last post by:
Hi I am new to visual basic. I write program to navigate & update data from table. My database is in Informix & use ODBC connection. When I nevigate the data it works properly. When I Update the record its also updated but after that if I try to navigate it its giving error "Row cannot be located for updating. Some values may have been change since it was last read". My code is as follows - Option Explicit Dim cnn As Connection Dim...
0
1046
by: gomzi | last post by:
hi, I have two update panels in my page, i would like the update progress to be shown only for one the panels. Right now, when either of the update panel gets updated with new data, the update progress gets called. thanks, gomzi.
1
9179
by: gabe | last post by:
How do you call a client side javascript callback method after an update panel has posted back to the server? I have two update panels (A + B) with a gridview in each panel. GridView B has a Trigger to listen when GridView A posts back from a Select button. This works fine. I can get the Postback from GridView B and I am able to update formatting of GridView B in it's PreRender Event.
1
1386
by: Microsoft Newsserver | last post by:
HI Im developing a solution in vs2005 with ajex extensions. Essentially I have three custom controls which render tables a representation as shown below. The problem is that when any of those buttons get clicked all three tables are updated. ( Buttons 1 2 and 3 are outside the panels ). How can I get ONLY the relevent panel to update ??
1
5025
by: SimonZ | last post by:
I have nested update panels. When I click on button, which is located in parent update panel, I would like that only child update panel is refreshed. Now the both panels are refreshed or none if I set ChildrenAsTriggers="false" on parent update panel. How can I do that? thanks, Simon
2
1434
by: Gotejjeken | last post by:
I've been using the Dojo Toolkit to implement Drag and Drop in my page, and all works fine until an asynchronous postback occurs, then the Javascript stops functioning. In my .NET page I have this in my Page_Load: ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "dojo", "<script type='text/javascript' src='/Pages/dojosource/dojo/dojo.js' djConfig='parseOnLoad: true'></script>", false); ...
2
2737
by: splendid9 | last post by:
how to associate 1 update progress to 2 update panels on a page. .i have a update panel which has a usercontrol inside that and the other update panel has a nextbutton and the update progress associatedupdatepanel to second one which has next button. so when i run the project there is a updateporgreess image but it is not doing anything it just kept on rolling witghout any result i did bind the button to updatepanel1...but that was of...
1
7527
by: anudu | last post by:
Hi, I have several update panels in my page. i want to call different javascript methods after the update panels are refreshed . i have attached the Sys.WebForms.PageRequestManager.getInstance().add_endRequest(MyMethod); at the end of the page and after an update panel is refreshed it is triggered. that method is like MyMethod(sender,args) . my problem is how can i identify which update panel is refreshed in side the MyMethod function? ...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.