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

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).Value= 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 4199
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*@discussions.microsoft.com> wrote in message
news:9D**********************************@microsof t.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).Value= 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.getElementById('txtTo').va lue);
var fromDate = makeDateObject(document.getElementById('txtFrom'). value);
daysDifference = toDate.getTime()-fromDate.getTime()
daysDifference = Math.floor(daysDifference / (1000*60*60*24)) + 1;
document.getElementById('txtTotal').value = daysDifference;
if (document.getElementById('txtTo').value.length == 0 ||
document.getElementById('txtFrom').value.length == 0)
return;
}

</script>

and from here i call it:

<td>
From: <div>
<input id=txtFrom onchange="Calculate"><A
onclick="window.open('Calendar.aspx?textbox=txtFro m','cal','width=300,height=300,left=470,top=300')"
href="javascript:;"><IMG src="images/SmallCalendar.gif" border="0"></A>

</div> To: <div>
<input id=txtTo onchange="javascript:Calculate();"><A
onclick="window.open('Calendar.aspx?textbox=txtTo' ,'cal','width=300,height=300,left=470,top=300')" href="javascript:;"><IMG
src="images/SmallCalendar.gif" 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).Value= 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.Attributes.Add("onclick","myClientFuncti on();");
-- bruce (sqlwork.com)
"Ali" <Al*@discussions.microsoft.com> wrote in message
news:9D**********************************@microsof t.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).Value= 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
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...
1
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...
3
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>...
0
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...
7
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....
0
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...
4
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>...
1
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...
8
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...
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
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
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,...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.