Solved

Calling a Server side sub from the onBlur event

Posted on 2009-07-08
1
779 Views
Last Modified: 2012-05-07
Hello Experts,

I have a form that needs to run a server-side function when the user tabs out of certain textboxes.  Right now it works great, except I'm using the TextChanged event.  What I really need is to run the same function, but with the onBlur event.

Now I realize that's asking client code to run a server function ... but that's really what I need here.  The textboxes are set to cause a postback, so it's already hitting the server.  The webpage is ajax enabled if that helps.  Any ideas?

Thanks!
0
Comment
Question by:GRCHELPDESK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
GRCHELPDESK earned 500 total points
ID: 24814484
Hello Experts,
Turns out this is far more tricky than I'd hoped.  This can be done, but the method is a little hacky.  To start you create the textbox for your onBlur event.  Then create a button to associate with the textbox.
Ex: txtFirstName & btnFirstName

In your Page load event, add this code:
Dim strEventHandler As String = Me.GetPostBackEventReference(Me.btnFirstName, "") Me.txtFirstName.Attributes.Add("onblur", strEventHandler)

Now, double click your button to create the event handler code.  Mission accomplished.  Enter in your blur code in the event handler of the button and it'll run on the blur event for the textbox.  Essentially, it's redirecting the client-side onBlur event of the textbox to the server-side click event of the button.  But sure to hide the button since since clicking it will cause the blur code to run.  And be sure to set the textbox as autopostback = true.
Hope this helps someone!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question