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

alert a serverside text box

Status
Not open for further replies.

HotBob

Programmer
May 26, 2006
37
GB
On my page load event in asp.net I populate a text box where it's visible property = false

i have a checkbox and on the click event I use:

function PC()
{
var i = document.getElementById("hiddenPC1");
alert(i);
}

However,I am receiving a value of null even though I know I have a value in the hiddenPC1 textbox.

Is it because I'm using a server side element, rather than a html element?
 
The null value means that the element just doesn't exist.

What does your HTML look like?

Cheers,
Dian
 
Yes your right, if I set the visible property to true then my elert is populated.

However, I am populating the text box on my asp.net page load event.

Can I populate a hidden textbox html element from my asp page load.

html
<code>
<asp:TextBox id="hiddenPC1" runat="server"></asp:TextBox>
</code>

asp.net
<code>
Me.hiddenPC1.Text = DI.Data.Tables("PCDN").Rows(0).Item("PC1")
</code>

Any ideas?
 
I have no idea of asp, if it's an asp question you should ask in the as forum.

Anyway, which HTML code produces that script?

Cheers,
Dian
 
HotBob, populating the hidden text field with ASP is as simple as placing the value into the field. I do not know how it would differ in .Net but my approach would be like this.
<%
myValue = "Something"
%>

<html>.....
<input id="hiddenPC1" type="hidden" value="<%=myValue%>">
....

As for doing a server-side alert, that is a different story.
Javascript will not do it server-side unless perhaps you are running server-side JScript. Even then, I do not know how you could possibly cause an alert or message box on the server console unless it is some feature that .Net is capable of. Normally the web application is going to run under the IUSR_machinename account and any server-side operations it performs execute under that account invisible to any current logon.


Google, you're my hero!
 
cool I've sorted it now.

Thanks anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top