473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 3427
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**********@gmail.comwrote in message
news:11*********************@q3g2000prf.googlegrou ps.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='doClick()'>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.GetCurrent(Page).RegisterClientScrip tBlock(Page,this.GetType(),"key1",
"$get('mycontrolid').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 16 '07 #3
Bruce,

good job,

can you use
ClientScript.RegisterClientScriptBlock( etc......)

what does ScriptManager.GetCurrent(Page). mean?

Thank u

"bruce barker" <no****@nospam.comwrote in message
news:%2****************@TK2MSFTNGP04.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='doClick()'>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.GetCurrent(Page).RegisterClientScrip tBlock(Page,this.GetType(),"key1",
"$get('mycontrolid').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 #4
just to confuse things there are two client managers.

Page.ClientScript 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.GetCurrent(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.RegisterClientScriptBlock( etc......)

what does ScriptManager.GetCurrent(Page). mean?

Thank u

"bruce barker" <no****@nospam.comwrote in message
news:%2****************@TK2MSFTNGP04.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='doClick()'>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.GetCurrent(Page).RegisterClientScri ptBlock(Page,this.GetType(),"key1",
"$get('mycontrolid').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**************@TK2MSFTNGP05.phx.gbl...
just to confuse things there are two client managers.

Page.ClientScript 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.GetCurrent(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.RegisterClientScriptBlock( etc......)

what does ScriptManager.GetCurrent(Page). mean?

Thank u

"bruce barker" <no****@nospam.comwrote in message
news:%2****************@TK2MSFTNGP04.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='doClick()'>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.GetCurrent(Page).RegisterClientScr iptBlock(Page,this.GetType(),"key1",
"$get('mycontrolid').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
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,...
1
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...
0
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...
1
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...
1
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...
1
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...
2
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...
2
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.