473,385 Members | 1,312 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,385 software developers and data experts.

how to get value of variable into textbox?

Hi,

i would like to get the value of variable 'em', defined in code-behind, into
a textbox.
I tried two ways but withoit succes (no error).

The first textbox is empty, the second gets:<%=em %>

aspx file:
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server" Text='<%# eval(em)
%>'></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" Text="<%=em
%>"></asp:TextBox>
</form>

code-behind:
Friend em As String
em = "ok"
Thanks
Cliff
Feb 14 '07 #1
2 19351
Cliff,

Since your textboxes are not inside one of the data bound controls
(GridView, FormView, etc.), you'll need to call Page.BindData() explicitly
and cannot use the Eval()/Bind() functions.

Change your aspx to:
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Me.em %>'></asp:TextBox>

Then in your codebehind call Page.DataBind():
.....

Protected em As String = ""

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Me.em = "Data binded on " & DateTime.Now.ToLongTimeString()
Page.DataBind()
End Sub

see also:
http://msdn2.microsoft.com/en-us/library/bda9bbfx.aspx

Hope this helps,
Jason Vermillion

"Cliff" wrote:
Hi,

i would like to get the value of variable 'em', defined in code-behind, into
a textbox.
I tried two ways but withoit succes (no error).

The first textbox is empty, the second gets:<%=em %>

aspx file:
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server" Text='<%# eval(em)
%>'></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" Text="<%=em
%>"></asp:TextBox>
</form>

code-behind:
Friend em As String
em = "ok"
Thanks
Cliff
Feb 14 '07 #2
Yes, thanks ..

"Jason Vermillion" <Ja*************@discussions.microsoft.comschree f in
bericht news:72**********************************@microsof t.com...
Cliff,

Since your textboxes are not inside one of the data bound controls
(GridView, FormView, etc.), you'll need to call Page.BindData() explicitly
and cannot use the Eval()/Bind() functions.

Change your aspx to:
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Me.em
%>'></asp:TextBox>

Then in your codebehind call Page.DataBind():
....

Protected em As String = ""

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Me.em = "Data binded on " & DateTime.Now.ToLongTimeString()
Page.DataBind()
End Sub

see also:
http://msdn2.microsoft.com/en-us/library/bda9bbfx.aspx

Hope this helps,
Jason Vermillion

"Cliff" wrote:
>Hi,

i would like to get the value of variable 'em', defined in code-behind,
into
a textbox.
I tried two ways but withoit succes (no error).

The first textbox is empty, the second gets:<%=em %>

aspx file:
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server" Text='<%# eval(em)
%>'></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" Text="<%=em
%>"></asp:TextBox>
</form>

code-behind:
Friend em As String
em = "ok"
Thanks
Cliff

Feb 14 '07 #3

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

Similar topics

5
by: velu | last post by:
Problem in getting value from textbox & radiobuttonlist to a valuable inside a datagid. I want to insert a record into a table thru datagrid. Here is the code (see below) Private Sub...
1
by: rudranee | last post by:
Hi everyone, I want to know how can i edit a value in textbox in html . I have a field where I have already put a value from database but i also want to edit it . for example ,if in a textbox i...
5
by: SKS | last post by:
hi all i would like to know how to restrict user from entering numeric value ina textbox..using C# if user try to enter text it shouldnt be allowed.. i tried errror provider.. but it doesnt met...
6
by: Chris | last post by:
I created a very simple web page in asp.net. there are only a textbox and a button on the page. when the page loads into web browser there is current date in the textbox. but the date can be...
1
by: abirami elango | last post by:
Hi, i have created a web application in vb.net. i have assigned a value to the textbox during page UNLOAD event as below.. ......... Protected Sub Page_Unload(ByVal sender As Object, ByVal e As...
3
by: vzrandom | last post by:
Hi guys, I have one easy question for you. I have class with public static variable. I enter value in one form (in this public static variable) and when I passed it to another form in textbox I...
1
by: adepvivek | last post by:
Hi everybody, I am using textbox in gridview as template. And I want to stored the value of textbox. For that I want to pass the textbox value to stored procedure. So please give me solution.
5
oranoos3000
by: oranoos3000 | last post by:
hi I want to send value of textbox without using form tag and submit button to another page? Is it possible with php ? How do I get this thing work? thanks alot
2
by: s k parimal | last post by:
How to validate decimal value in textbox using C#? I am using this (^(*|\d*\d{1}?\d*)$) but it not working help
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.