Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   How-to? - Process Client-side AND Server-side Code Blocks With aspnet Button (http://www.velocityreviews.com/forums/t116622-how-to-process-client-side-and-server-side-code-blocks-with-aspnet-button.html)

Joey 01-03-2006 10:10 PM

How-to? - Process Client-side AND Server-side Code Blocks With aspnet Button
 
I have a web application with a page where user can go to upload data
files. When they click "Upload", which is an aspnet Button, I want to
be able to instantly hide a couple of textboxes and buttons on the
webpage before doing the postback. This is because if I place code to
do this in the server-side code block, it doesn't get executed until
after the upload completes - not very useful for this scenario! And so
I thought I would put in some client-side javascript to do the job .
But how do I wire up the client side function to the aspnet Button? I
need to be able to execute the client side javascript code block and
then immediately execute the server side code block afterwards. The
runat="server" is required for the aspnet Button, or at least that's
what the VS2005 compiler says. So how can I accomplish this?


=?Utf-8?B?aGVpbg==?= 01-03-2006 11:01 PM

RE: How-to? - Process Client-side AND Server-side Code Blocks With asp
 
Hi Joey,

You can add an attribute to the button for example by overriding the page
prerender event:
protected override void OnPreRender(EventArgs e)
{
Button1.Attributes["onclick"]="alert('clicked')";
base.OnPreRender (e);
}
Substitute the alert by your client script.
Hope this helps.


"Joey" wrote:

> I have a web application with a page where user can go to upload data
> files. When they click "Upload", which is an aspnet Button, I want to
> be able to instantly hide a couple of textboxes and buttons on the
> webpage before doing the postback. This is because if I place code to
> do this in the server-side code block, it doesn't get executed until
> after the upload completes - not very useful for this scenario! And so
> I thought I would put in some client-side javascript to do the job .
> But how do I wire up the client side function to the aspnet Button? I
> need to be able to execute the client side javascript code block and
> then immediately execute the server side code block afterwards. The
> runat="server" is required for the aspnet Button, or at least that's
> what the VS2005 compiler says. So how can I accomplish this?
>
>



All times are GMT. The time now is 01:10 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.