By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,594 Members | 3,459 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,594 IT Pros & Developers. It's quick & easy.

accessing Input text values from my code behind

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.