Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > AJAX, Intercept Submit before it happens

Reply
Thread Tools

AJAX, Intercept Submit before it happens

 
 
Lit
Guest
Posts: n/a
 
      07-30-2007
Hi,

I have an update panel with a Submit Button. ( AJAXified )

Is there a way, good way, of Intercepting a submit before it happens?

I would like to do something in JavaScript before proceeding with the submit
process.

How to Inject such JavaScript from Code Behind?

Thank You,

Lit



 
Reply With Quote
 
 
 
 
Larry Bud
Guest
Posts: n/a
 
      07-30-2007
On Jul 30, 12:44 pm, "Lit" <(E-Mail Removed)> wrote:
> Hi,
>
> I have an update panel with a Submit Button. ( AJAXified )
>
> Is there a way, good way, of Intercepting a submit before it happens?
>
> I would like to do something in JavaScript before proceeding with the submit
> process.
>
> How to Inject such JavaScript from Code Behind?
>
> Thank You,
>
> Lit


OnClientClick for the button. If you return TRUE, the action will
occur.

 
Reply With Quote
 
 
 
 
Lit
Guest
Posts: n/a
 
      07-30-2007
Larry,

Excellent ( For the Submit Button ), What about something like a ListBox
Control that does not have OnClientClick that I can see.

Thanks for your quick reply.

Lit.

"Larry Bud" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> On Jul 30, 12:44 pm, "Lit" <(E-Mail Removed)> wrote:
>> Hi,
>>
>> I have an update panel with a Submit Button. ( AJAXified )
>>
>> Is there a way, good way, of Intercepting a submit before it happens?
>>
>> I would like to do something in JavaScript before proceeding with the
>> submit
>> process.
>>
>> How to Inject such JavaScript from Code Behind?
>>
>> Thank You,
>>
>> Lit

>
> OnClientClick for the button. If you return TRUE, the action will
> occur.
>



 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      07-30-2007
"Lit" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> Excellent ( For the Submit Button ), What about something like a ListBox
> Control that does not have OnClientClick that I can see.


MyListBox.Attributes.Add("onclick", "alert('Clicked');");


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
Lit
Guest
Posts: n/a
 
      07-30-2007
Mark,

If I already have an onclick - server event, how do I Intercept before I
post back?

or how do I intercept the OnSelectedIndexChanged event in JavaScript. Is it
called something else for the ListBox on the client side?

Does the Client script event handler get executed then the server event
handler after the post?

Thank much for your time

Lit



"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Lit" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> Excellent ( For the Submit Button ), What about something like a ListBox
>> Control that does not have OnClientClick that I can see.

>
> MyListBox.Attributes.Add("onclick", "alert('Clicked');");
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      07-30-2007
"Lit" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> If I already have an onclick - server event, how do I Intercept before I
> post back?


Larry's already answered that... You add a client-side onclick event and
capture the return value - if it's false, the postback won't happen...

> or how do I intercept the OnSelectedIndexChanged event in JavaScript. Is
> it called something else for the ListBox on the client side?


An <asp:ListBox> webcontrol gets rendered as an HTML <select> - you need the
onchange event...

> Does the Client script event handler get executed then the server event
> handler after the post?


Yes, unless the client-side event returns false...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      07-30-2007
see RegisterOnSubmitStatement

-- bruce (sqlwork.com)

Lit wrote:
> Hi,
>
> I have an update panel with a Submit Button. ( AJAXified )
>
> Is there a way, good way, of Intercepting a submit before it happens?
>
> I would like to do something in JavaScript before proceeding with the submit
> process.
>
> How to Inject such JavaScript from Code Behind?
>
> Thank You,
>
> Lit
>
>
>

 
Reply With Quote
 
Lit
Guest
Posts: n/a
 
      07-30-2007
Mark,

"onchange" is what I was looking for.

Thanks for the help

Lit.


"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> "Lit" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> If I already have an onclick - server event, how do I Intercept before I
>> post back?

>
> Larry's already answered that... You add a client-side onclick event and
> capture the return value - if it's false, the postback won't happen...
>
>> or how do I intercept the OnSelectedIndexChanged event in JavaScript. Is
>> it called something else for the ListBox on the client side?

>
> An <asp:ListBox> webcontrol gets rendered as an HTML <select> - you need
> the onchange event...
>
>> Does the Client script event handler get executed then the server event
>> handler after the post?

>
> Yes, unless the client-side event returns false...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What happens when type conversion between signed and unsigned happens? NM C++ 6 09-20-2006 05:39 PM
Is there a way to intercept page HTML source before it's served LP ASP .Net 5 02-19-2005 08:18 PM
httphandler to intercept pages before sent to user =?Utf-8?B?cnBhbGU=?= ASP .Net 2 12-16-2004 07:37 AM
Can you intercept the url request before a 404 error occurs? =?Utf-8?B?UlVTU0VMTCBNQ0dJTk5JUw==?= ASP .Net 1 07-14-2004 02:45 PM
Intercept html before rendering Adam Smith ASP .Net 6 05-27-2004 09:15 AM



Advertisments