Solved

Calling a Server side sub from the onBlur event

Posted on 2009-07-08
1
755 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

Suggested Solutions

Title # Comments Views Activity
How to filter by key press ? 6 66
orderby list (from Json) 1 44
ASP.net Moving Visual Studio 2015 project to 2017 2 71
asp.net, radiobuttonlist, c# 3 69
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 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