473,782 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

accessing Input text values from my code behind

Ali
I have 3 html input tex in my asp.net form. Two of them are calling
javascript client side to calculate the differnce of two dates and put the
result into the third input text. i haven't include runat=server in those
input texts. it works fine with me and i get the result in the third input
text. Now when i want to insert the 3 html input text values into my database
among other web controls ... i found out that i can't see them unlike web
controls such as textbox and dropdownlist ... it's suggesting me to declare
them first before i use them
so i did something like :
Dim txtFrom as HtmlInputText
Dim txtTo as HtmlInputText
and i tried but i am not getting the value even though i set to:

SqldataAdapter1 .Insertcommand. Parameters(1).V alue= txtFrom.Value

so what's the solution then? I tried to put runat="server" inside the
input text tag but them my function call is not working.
Nov 19 '05 #1
3 4229
Well
Try removing the declarations from the class
And after that go to the design HTML view and put Name , ID and Runat=server
and switch from Design To Preview And Back.

"Ali" <Al*@discussion s.microsoft.com > wrote in message
news:9D******** *************** ***********@mic rosoft.com...
I have 3 html input tex in my asp.net form. Two of them are calling
javascript client side to calculate the differnce of two dates and put the
result into the third input text. i haven't include runat=server in those
input texts. it works fine with me and i get the result in the third input
text. Now when i want to insert the 3 html input text values into my database among other web controls ... i found out that i can't see them unlike web
controls such as textbox and dropdownlist ... it's suggesting me to declare them first before i use them
so i did something like :
Dim txtFrom as HtmlInputText
Dim txtTo as HtmlInputText
and i tried but i am not getting the value even though i set to:

SqldataAdapter1 .Insertcommand. Parameters(1).V alue= txtFrom.Value

so what's the solution then? I tried to put runat="server" inside the
input text tag but them my function call is not working.

Nov 19 '05 #2
Ali
Here's the client side function i call :
function Calculate()
{

var toDate = makeDateObject( document.getEle mentById('txtTo ').value);
var fromDate = makeDateObject( document.getEle mentById('txtFr om').value);
daysDifference = toDate.getTime( )-fromDate.getTim e()
daysDifference = Math.floor(days Difference / (1000*60*60*24) ) + 1;
document.getEle mentById('txtTo tal').value = daysDifference;
if (document.getEl ementById('txtT o').value.lengt h == 0 ||
document.getEle mentById('txtFr om').value.leng th == 0)
return;
}

</script>

and from here i call it:

<td>
From: <div>
<input id=txtFrom onchange="Calcu late"><A
onclick="window .open('Calendar .aspx?textbox=t xtFrom','cal',' width=300,heigh t=300,left=470, top=300')"
href="javascrip t:;"><IMG src="images/SmallCalendar.g if" border="0"></A>

</div> To: <div>
<input id=txtTo onchange="javas cript:Calculate ();"><A
onclick="window .open('Calendar .aspx?textbox=t xtTo','cal','wi dth=300,height= 300,left=470,to p=300')" href="javascrip t:;"><IMG
src="images/SmallCalendar.g if" border="0"> </A>

</div>
</td>

I am getting the result of the difference into this :

<td style="height: 34px">
<input id=txtTotal />
</td>

it's working properly... just the inserting thing .. any help will be
highly appreciated
"Ali" wrote:
I have 3 html input tex in my asp.net form. Two of them are calling
javascript client side to calculate the differnce of two dates and put the
result into the third input text. i haven't include runat=server in those
input texts. it works fine with me and i get the result in the third input
text. Now when i want to insert the 3 html input text values into my database
among other web controls ... i found out that i can't see them unlike web
controls such as textbox and dropdownlist ... it's suggesting me to declare
them first before i use them
so i did something like :
Dim txtFrom as HtmlInputText
Dim txtTo as HtmlInputText
and i tried but i am not getting the value even though i set to:

SqldataAdapter1 .Insertcommand. Parameters(1).V alue= txtFrom.Value

so what's the solution then? I tried to put runat="server" inside the
input text tag but them my function call is not working.

Nov 19 '05 #3
you have two options:

1) fetch the postback value from the Request.Form collection

Request.Form["fieldname"]

2) place a runat=server on the textbox, and in the codebehind use the
attributes collection to add the client handler:

myTextBox.Attri butes.Add("oncl ick","myClientF unction();");
-- bruce (sqlwork.com)
"Ali" <Al*@discussion s.microsoft.com > wrote in message
news:9D******** *************** ***********@mic rosoft.com...
I have 3 html input tex in my asp.net form. Two of them are calling
javascript client side to calculate the differnce of two dates and put the
result into the third input text. i haven't include runat=server in those
input texts. it works fine with me and i get the result in the third input
text. Now when i want to insert the 3 html input text values into my
database
among other web controls ... i found out that i can't see them unlike web
controls such as textbox and dropdownlist ... it's suggesting me to
declare
them first before i use them
so i did something like :
Dim txtFrom as HtmlInputText
Dim txtTo as HtmlInputText
and i tried but i am not getting the value even though i set to:

SqldataAdapter1 .Insertcommand. Parameters(1).V alue= txtFrom.Value

so what's the solution then? I tried to put runat="server" inside the
input text tag but them my function call is not working.

Nov 19 '05 #4

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

Similar topics

6
2746
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is called "form1", and I have selects called "PORTA", "PORTB" ... etc...
1
3139
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created elements and would like to seek a solution for this. I had looked through several articles for accessing programatically-created dynamic elements such as: 1)
3
1635
by: Magnus Blomberg | last post by:
Hello! I have a client javascript that generates a string (like below). This string should then be used by server code (in this case a function called run). <script language=javascript> function getpic() { string s; s = document.getElementById("File1").getAttribute("value"); <% run(s); %> }
0
12088
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the likelihood of CRM success from less than 20 percent to 60 percent. WHITEPAPER :
7
2608
by: Nez | last post by:
Help needed! Hello, I have looked everywhere for a solution to my problem and this is pretty much my last resource. I have created a table in a span with the innerhtml command in my code behind. In this table I have created textbox html input fields. Now I need to allow the user to change the value in the textfield, and compare it to the old value I have stored in a cookie. Problem is, because the textfield was created in the code...
0
2810
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of chkAll. I simply want to have chkAll be checked if every item in the repeater has its checkbox checked. In the code behind page, I can access the checked property of chkReconciled by doing the following: Dim CurrentCheckBox As CheckBox...
4
1466
by: =?Utf-8?B?R3JlZyBTdGV2ZW5z?= | last post by:
I have an ASP.NET page with a form that contains two user controls: <%@ Register TagPrefix="x" TagName="c1" Src="ctl1.ascx" %> <%@ Register TagPrefix="x" TagName="c2" Src="ctl2.ascx" %> <body> <form runat="Server"> <x:c1 id="con1" runat="Server"> <x:c2 id="con2" runat="Server"> <form> </body>
1
1653
by: Jeff User | last post by:
hi all Using C#, .NET1.1. I need to pass a string of text to the final html output and then capture it with java script on the client side. I found that I can place my string in and then access a textbox or a label from the js, but only if the textbox or label is visible. If they are hidden (and then need to be) then they are not created in the html output.
8
10841
by: GaryDean | last post by:
I have a Wizard page and need to affect the next and previous buttons from my code-behind. I've googled around and found two solutions, and neither appear to work. I can access the SideBarList steps successfully with the following code... Control myContainer = (Control)Wizard1.FindControl("SideBarContainer"); DataList mySideBarList = (DataList)myContainer.FindControl("SideBarList");
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9946
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.