473,399 Members | 3,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

textbox.value not available yet

hey all,
i'm running the following:
ScriptManager.RegisterClientScriptBlock in my OnInit event.

well the javascript function that it runs assigns a value to a webserver
textbox control.

after it's finish running this script it control comes back to the
server-side and when i try to inspect the textbox it is still empty, however
when the page finishes loading the correct value appears in the textbox.

is there a certain event i can see the correct value in the code behind
before the page appears?

thanks,
rodchar
Jul 9 '08 #1
5 1868
"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:D9**********************************@microsof t.com...
Is there a certain event i can see the correct value in the code behind
before the page appears?
What happens is that ASP.NET does all the server-side processing until it's
finished. This results in an HTML stream. This gets streamed down to the
client browser where it gets rendered from top to bottom.

RegisterClientScriptBlock creates a JavaScript block immediately below the
<form runat="server"tag. At that moment, none of the rest of the form
elements have been created yet. If your JavaScript block needs to reference
any of the form elements, it needs to appear after them in the HTML stream.
For that, you need RegisterStartupScript. This creates the script block just
above the closing </formtag.

http://it.toolbox.com/blogs/coding-d...upscript-17321
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 9 '08 #2
thank you for the help Mark,
rod.

"Mark Rae [MVP]" wrote:
"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:D9**********************************@microsof t.com...
Is there a certain event i can see the correct value in the code behind
before the page appears?

What happens is that ASP.NET does all the server-side processing until it's
finished. This results in an HTML stream. This gets streamed down to the
client browser where it gets rendered from top to bottom.

RegisterClientScriptBlock creates a JavaScript block immediately below the
<form runat="server"tag. At that moment, none of the rest of the form
elements have been created yet. If your JavaScript block needs to reference
any of the form elements, it needs to appear after them in the HTML stream.
For that, you need RegisterStartupScript. This creates the script block just
above the closing </formtag.

http://it.toolbox.com/blogs/coding-d...upscript-17321
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 10 '08 #3
http://pastebin.com/m661ec734

At the time of the button click event Text1.value is still blank, is there
any point where i can get this populate correctly?

"Mark Rae [MVP]" wrote:
"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:D9**********************************@microsof t.com...
Is there a certain event i can see the correct value in the code behind
before the page appears?

What happens is that ASP.NET does all the server-side processing until it's
finished. This results in an HTML stream. This gets streamed down to the
client browser where it gets rendered from top to bottom.

RegisterClientScriptBlock creates a JavaScript block immediately below the
<form runat="server"tag. At that moment, none of the rest of the form
elements have been created yet. If your JavaScript block needs to reference
any of the form elements, it needs to appear after them in the HTML stream.
For that, you need RegisterStartupScript. This creates the script block just
above the closing </formtag.

http://it.toolbox.com/blogs/coding-d...upscript-17321
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 10 '08 #4
Looks expected from the code :

- Do you want to do this on the first run (in which case this is when you
!IsPostBack) ?

- Note also that you have a server side processing first then once the page
is rendered, javascript code will run client side (in this case the js code
will run after the event is procesed server side).

Your best bet is perhaps to explain what you are trying to do (if you want
to provide a default value you could this server side for example possibly
just in the markup)...

--
Patrice
"rodchar" <ro*****@discussions.microsoft.coma écrit dans le message de
groupe de discussion : FB**********************************@microsoft.com...
http://pastebin.com/m661ec734

At the time of the button click event Text1.value is still blank, is there
any point where i can get this populate correctly?

"Mark Rae [MVP]" wrote:
>"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:D9**********************************@microso ft.com...
Is there a certain event i can see the correct value in the code behind
before the page appears?

What happens is that ASP.NET does all the server-side processing until
it's
finished. This results in an HTML stream. This gets streamed down to the
client browser where it gets rendered from top to bottom.

RegisterClientScriptBlock creates a JavaScript block immediately below
the
<form runat="server"tag. At that moment, none of the rest of the form
elements have been created yet. If your JavaScript block needs to
reference
any of the form elements, it needs to appear after them in the HTML
stream.
For that, you need RegisterStartupScript. This creates the script block
just
above the closing </formtag.

http://it.toolbox.com/blogs/coding-d...upscript-17321
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 10 '08 #5
- Do you want to do this on the first run (in which case this is when you
!IsPostBack) ?
No, I do need it to run on postback.

I have an .aspx page in which all controls are dynamic and i don't know what
the first textbox id will be until runtime.
This is where the javascript function comes into play it determines the
first textbox and places its id in a hidden control where i thought i could
pick it up on server-side.

I''m having to do all this because I have an Ajax UpdatePanel that seems to
overriding any kind of focus i try to set and the very last moment.
I found where you can use ScriptManager.SetFocus and this seems to be the
answer.

"Patrice" wrote:
Looks expected from the code :

- Do you want to do this on the first run (in which case this is when you
!IsPostBack) ?

- Note also that you have a server side processing first then once the page
is rendered, javascript code will run client side (in this case the js code
will run after the event is procesed server side).

Your best bet is perhaps to explain what you are trying to do (if you want
to provide a default value you could this server side for example possibly
just in the markup)...

--
Patrice
"rodchar" <ro*****@discussions.microsoft.coma crit dans le message de
groupe de discussion : FB**********************************@microsoft.com...
http://pastebin.com/m661ec734

At the time of the button click event Text1.value is still blank, is there
any point where i can get this populate correctly?

"Mark Rae [MVP]" wrote:
"rodchar" <ro*****@discussions.microsoft.comwrote in message
news:D9**********************************@microsof t.com...

Is there a certain event i can see the correct value in the code behind
before the page appears?

What happens is that ASP.NET does all the server-side processing until
it's
finished. This results in an HTML stream. This gets streamed down to the
client browser where it gets rendered from top to bottom.

RegisterClientScriptBlock creates a JavaScript block immediately below
the
<form runat="server"tag. At that moment, none of the rest of the form
elements have been created yet. If your JavaScript block needs to
reference
any of the form elements, it needs to appear after them in the HTML
stream.
For that, you need RegisterStartupScript. This creates the script block
just
above the closing </formtag.

http://it.toolbox.com/blogs/coding-d...upscript-17321
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 10 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I have a problem with capturing the changed value of a text box in a datagrid. The datagrid is populated based on a dataset and I am using template...
14
by: Adam Clauss | last post by:
I've an application which is using a multiline textbox to log the status of a fairly long procedure. "Updates" are made to the status by calling textbox.AppendText. As my task is fairly lengthy,...
1
by: David Smith | last post by:
What I want to be able to do: A textbox is available that the user can enter information into. Specifically (for the purposes of this post), the user is asked to enter a number, and that number...
3
by: Justin Morris via DotNetMonster.com | last post by:
<asp:TextBox ID="TextBox1" runat="server" value='<%=Server.HtmlEncode (Request.Cookies("Username")("Username"))%>'/> <input name="Password" type="text" id="Password" value='<%...
11
by: Keith | last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing...
5
by: Ken Varn | last post by:
I have just started using VS.NET 2005 after using VS.NET 2003. One of the things that I noticed is that in ASP.NET, the DataSource property for TextBoxes and other web controls is no longer...
3
by: AlecL | last post by:
Hi All, I am trying to capture the value of a textbox as a result of a button click event in a repeater, but it can't find the textbox. Here is what I am trying to do in the code for the click...
16
by: mj.redfox.mj | last post by:
Can anyone help? I have a textbox which I'm programatically adding by using the following code: txtTest = New TextBox txtTest.ID = "txtLeft" + cntCount.ToString...
10
by: pt36 | last post by:
Hi I have a page with a form and a textbox. before to submit the form I want to chek if the inserted value in the textbox is already present in a database. So I need to pass the textbox value...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.