Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[b]Force Text.TextChanged Event. How?[/b]

Status
Not open for further replies.

mjjks

Programmer
Joined
Jun 22, 2005
Messages
138
Location
US
Quick foreword.
I have a textbox web forms control and an image.
On image click, I open popup window, load grid with data and return selected value into textbox using JavaScript.

I need to be able to fire TextChanged event when data is placed into textbox via JavaScript, so I can do further processing in that event in code behind.
Right now this event fires only if I type something in textbox and tab.


Thanks much for your help

Steve
 
When you come back to the page, I belive a post back happens. So, what I would do is store the value (on the first page) into a session var. Then when you come back, check the value against the session var, and if it is different fire the event.

As for fireing the event, you can call the event directly but it is cumbersome and proabaly not the best way in .NET. In other languages you can do it simply, but with .NET it is a pain. So, what you can do is put the code in the Text Changed event into a sub. Then from the TextChanged event call that sub. Also, when you check the session var in the Page_Load, fire the event if the values are not =.


Jim
 
Thanks Jim. I'll give it a try.
 
OK.. let me know how it goes and if I can help any further...


Jim
 
I tried but postback is not happening as I populate parent forms control via javascript using opener.document.myformname.mycontrol.value='12345'

I'll need somehow to force LoadPage event from JavaScript and in Loadpage event, compare values and then call textChanged.

I'm just started with ASP.Net, so don't really know if it's possible to do using Javascriipt.

I was thinking to place a value into parent control and then submit form using javascript. That should force parent page reload.
 
Too much JavaScript for me... LOL

How are you returning to the main page?

Jim


 
Jim,
I simply populate main page's textbox from popup and close popup.

Javascript popup wasn't my choice but I don't have much space on form for lookups and user needs to stay on the same page pretty much all the time.

It's more like a windows form functionality duplication

Thanks

Steve
 
when you come back to the main page.. the page_load isn't firing?
 
nope, it's not
 
humm I thought it would.. it does when i have done it in the past.. what is the code you use to close the pop up and send back to the main page?
 
Code:
<script language="JavaScript" type="text/javascript">
   function passValBack(x)
    {
     opener.document.header.txtOrderNo.value= x;
     opener.document.header.txtOrderNo.focus();
     close();
    }
</script>
 
Yes you are right.. the Page_Load does not fire. Maybe in your code you can call opener.document.forms[0].submit before you close the window.


Jim
 
Thanks Jim for you suggestions but I abandoned that approach.

I created a hidden layer and placed grid on it and show/hide it using javascript in image button.

I thought that would do the trick and it does in a way.
Problem is that image button submits form, page reloads and I see layer with grid for a second as initially layer is hidden.

Is there a way to prevent button from posting form?
Image button doesn't have AutoPostback property.

I'll probably post this as separate question.

Thanks everyone
 
Any type of server button automatically causes a postback and there is no way to turn it off.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top