Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

AJAX, Intercept Submit before it happens

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lit - 30 Jul 2007 17:44 GMT
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
Larry Bud - 30 Jul 2007 17:52 GMT
> Hi,
>
[quoted text clipped - 10 lines]
>
> Lit

OnClientClick for the button.  If you return TRUE, the action will
occur.
Lit - 30 Jul 2007 17:58 GMT
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.

>> Hi,
>>
[quoted text clipped - 14 lines]
> OnClientClick for the button.  If you return TRUE, the action will
> occur.
Mark Rae [MVP] - 30 Jul 2007 18:22 GMT
> 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');");

Signature

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

Lit - 30 Jul 2007 19:34 GMT
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

>> 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 [MVP] - 30 Jul 2007 19:46 GMT
> 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...

Signature

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

Lit - 30 Jul 2007 23:07 GMT
Mark,

"onchange"  is what I was looking for.

Thanks for the help

Lit.

>> If I already have an onclick - server event, how do I Intercept before I
>> post back?
[quoted text clipped - 12 lines]
>
> Yes, unless the client-side event returns false...
bruce barker - 30 Jul 2007 20:44 GMT
see RegisterOnSubmitStatement

-- bruce (sqlwork.com)

> Hi,
>
[quoted text clipped - 10 lines]
>
> Lit

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.