Solved

Calling a Server side sub from the onBlur event

Posted on 2009-07-08
1
708 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
1 Comment
 
LVL 2

Accepted Solution

by:
GRCHELPDESK earned 500 total points
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now