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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server control textbox values at runtime

Status
Not open for further replies.

CylonLove4Life

Technical User
Feb 15, 2005
53
ES
I'm working on a ASP.NET page and have a porb:

I have a textbox whose value I should pick and send as a parameter to a JavaScript function.

The JS function will subsequently open a new window and pass the value on to the new window for processing.

How do I get the value in the textbox at runtime? I tried document.getElementByID, but since the text box is a server control, this method doesntm work.

Note: I cant make the textbox a plain HTML control for various reasons
 
You should still be able to access server controls in javascript in exactly the same way.

Ther other alternative is to add the javascript function server-side by using Attributes.Add

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
But my textbox's id becomes scrambled by the server. SO I can't access it by using

document.getElementByID

because e_txtbx beacomes _ctl7:e_txtbx or something like that.

Is there some other way?
 
because e_txtbx beacomes _ctl7:e_txtbx or something like that.
So it's not just a standatd Textbox on a page then? Is it part of a DataGrid or something similar?

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
ca8msm,

I understand from your reply that if its a plain webserver textbox control then the id shouldnt get scrambled.

I need to cross check whats happening in my code and come back, the app architecture is complex.
 
Yes thats correct - If you just drop a TextBox on a form the id will remain the same - it's only if that TextBox is part of a control that means it will be repeated, that the id gets automatically assigned.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top