assign a varriable to text box

G

Ganesh

Hi There,

I'm trying to use a variable value in the text box, i cannot find a way to
do this.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="c#">
string a12 ="89";
page.databind();
</script>



</head><body>
<form id="form1" runat="server">
<div><asp:TextBox ID="TextBox1" runat="server" text ="<%= a12 %>"
Style="z-index: 100; left: 120px; position: absolute;top:
104px"></asp:TextBox></div></form></body></html>

Thanks
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Ganesh said:
Hi There,

I'm trying to use a variable value in the text box, i cannot find a way to
do this.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="c#">
string a12 ="89";
page.databind();
</script>

</head><body>
<form id="form1" runat="server">
<div><asp:TextBox ID="TextBox1" runat="server" text ="<%= a12 %>"
Style="z-index: 100; left: 120px; position: absolute;top:
104px"></asp:TextBox></div></form></body></html>

Thanks

You use the <%# tag for databinding, not the <%= tag. Also you need
runat="server" on your script tag, otherwise the script will not execute
on the server, but instead be sent to the browser, where it will be
ignored as the browser don't know C# code.

I would skip the databinding altogehter, though:

<script language="C#" runat="server">
TextBox1.Text = "89";
</script>

<asp:TextBox ID="TextBox1" runat="server"
Style="z-index:100;left:120px;position:absolute;top:104px"/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top