473,385 Members | 1,673 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.

Assign to a HTML textbox a value with asp.net

I had to create a HTML textbox to add the date time but I don't know how to
assign the value with asp.net, how can I do that?

This is my HTM Textbox code:

<input id="txtFechaPlan" name="txtFechaPlan" style="width: 124px; position:
static" type="text" />

Thx

Nov 17 '08 #1
5 9622
"egsdar" <eg****@discussions.microsoft.comwrote in message
news:FB**********************************@microsof t.com...
I had to create a HTML textbox to add the date time but I don't know how
to
assign the value with asp.net, how can I do that?

This is my HTM Textbox code:

<input id="txtFechaPlan" name="txtFechaPlan" style="width: 124px;
position:
static" type="text" />
Change the client-side markup to:
<input type="text" id="txtFechaPlan" runat="server"
style="width:124px;position:static;" />

Add the following to the code-behind, probably in the Page_Load event:
txtFechaPlan.Text = DateTime.Now.ToString("dd MMM yyyy HH:mm");
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 17 '08 #2
Try :
http://quickstarts.asp.net/QuickStar...px#serverctrls

<input type="text" runat="server"will use server side a programming model
that closely match the one used client side.

You can also use an <asp:TextBox runat="server"control that will use
server side a programming model that is similar to Windows Forms (but
ultimately it will of course still be rendered as an input type="text"
markup...

--
Patrice

"egsdar" <eg****@discussions.microsoft.coma écrit dans le message de
groupe de discussion : FB**********************************@microsoft.com...
I had to create a HTML textbox to add the date time but I don't know how
to
assign the value with asp.net, how can I do that?

This is my HTM Textbox code:

<input id="txtFechaPlan" name="txtFechaPlan" style="width: 124px;
position:
static" type="text" />

Thx
Nov 17 '08 #3
In other words, we can add runat="server" to --any-- HTML element and it can
then be parsed and compiled as an HTML Control. If you need to reference an
HTML Control it must be typed as HtmlGenericControl, i.e.

HtmlGenericControl textInput = FindControl("txtFechaPlan") as
HtmlGenericControl;

//search
html control site:msdn.microsoft.com


"egsdar" <eg****@discussions.microsoft.comwrote in message
news:FB**********************************@microsof t.com...
>I had to create a HTML textbox to add the date time but I don't know how to
assign the value with asp.net, how can I do that?

This is my HTM Textbox code:

<input id="txtFechaPlan" name="txtFechaPlan" style="width: 124px;
position:
static" type="text" />

Thx
Nov 18 '08 #4
Thanks for the post, but I did as you suggest and it works, however, this
textbox is associated with a script and when I add the runat tag the
javascript doesn't work, this is the full aspx code:

<input id="txtFechaPlan" name="txtFechaPlan" style="width: 124px; position:
static" type="text" runat="server" />

<a href="javascript:NewCal('txtFechaPlan','yyyymmdd', true,24,'arrow')">

<img src="Images/date.png" style="position: static" border="0" /></a>

How can I make them both work?
"Mark Rae [MVP]" wrote:
"egsdar" <eg****@discussions.microsoft.comwrote in message
news:FB**********************************@microsof t.com...
I had to create a HTML textbox to add the date time but I don't know how
to
assign the value with asp.net, how can I do that?

This is my HTM Textbox code:

<input id="txtFechaPlan" name="txtFechaPlan" style="width: 124px;
position:
static" type="text" />

Change the client-side markup to:
<input type="text" id="txtFechaPlan" runat="server"
style="width:124px;position:static;" />

Add the following to the code-behind, probably in the Page_Load event:
txtFechaPlan.Text = DateTime.Now.ToString("dd MMM yyyy HH:mm");
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 18 '08 #5
"egsdar" <eg****@discussions.microsoft.comwrote in message
news:73**********************************@microsof t.com...
>Change the client-side markup to:
<input type="text" id="txtFechaPlan" runat="server"
style="width:124px;position:static;" />

Add the following to the code-behind, probably in the Page_Load event:
txtFechaPlan.Text = DateTime.Now.ToString("dd MMM yyyy HH:mm");

Thanks for the post, but I did as you suggest and it works, however, this
textbox is associated with a script and when I add the runat tag the
javascript doesn't work, this is the full aspx code:

<input id="txtFechaPlan" name="txtFechaPlan" style="width: 124px;
position:
static" type="text" runat="server" />

<a href="javascript:NewCal('txtFechaPlan','yyyymmdd', true,24,'arrow')">

<img src="Images/date.png" style="position: static" border="0" /></a>
As a general rule, when posting to a technical newsgroup, there is very
little point in saying simply that something "doesn't work" if you don't
actually say why it doesn't work, what error messages you are getting etc.
That will help us to help you. All I can do now is guess why it doesn't
work...

Firstly, remove the name="txtFechaPlan" tag, as I originally advised e.g.
<input type="text" id="txtFechaPlan" runat="server"
style="width:124px;position:static" />

Then try this:
<a
href="javascript:NewCal('<%=txtFechaPlan.ClientID% >','yyyymmdd',true,24,'arrow')">

As mentioned, I can't guarantee this will solve your problem because you
haven't explained what your problem is...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 18 '08 #6

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

Similar topics

2
by: dskillingstad | last post by:
I'm trying to assign a custom value to a textbox. Here's what I have. I've created a module and "default value" code for a textbox which generates a custom auto-number (yyyy-0000) when a New...
12
by: Mark Kurten | last post by:
i have the code below: for starters the value of txtempid = 1 after i go through this routine (i put a break point on the txtname.value line), the value of txtEmpID is 2 (Just like it is...
2
by: Grey | last post by:
I want to assign a value to HMTL textbox with id "txtABC" in ASP.NET with C#
1
by: Shilpi Chaudhry | last post by:
I have a forloop which I use to create textboxes - but unfortunately all of them have the same ids - I need to assign different ids to these textboxes creeated in the loop so that I can retrieve...
8
by: Sergei | last post by:
Hi, I am displaying modal dialog and passing values from the main form to the modal dialog and back. It works fine but if I used the following syntax on Page_Load(just for testing) in VB to...
15
by: Swetha | last post by:
Hello I have a DropDownList that I am populating using the following SqlDataSource: <asp:DropDownList ID="parentIDDropDownList" runat="server" DataSourceID="SqlDataSource3"...
6
by: david | last post by:
I try to use "for" loop to retrieve and assign values in web form. The code is in the following. But it can not be compiled. What I want to do is: txtQ1.Text =...
3
by: hugo | last post by:
Hi, I have a function that I call from form fields using the OnKeyUp function to replace special caracters. Once this function has been called, it does not set the focus on the form field where...
5
by: lianping | last post by:
Hi, I have a problem to assign a value into text box, below will be my script. Before view my script, let me hv quick explain on what is my problem: I would like to assign Java script value...
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: 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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.