Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Calling a Server side sub from the onBlur event

Posted on 2009-07-08
1
Medium Priority
?
798 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

670 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