setting non server control values: input type="text" how to set value programmatically?


<

form id="someForm" runat="server" enableviewstate="true">
  <input id="manualtextbox" type="text" value="abc" name="manualtextbox" />
</form>

I have access to user supplied value via:

string userEnteredThisInForm = Request.Params[

"manualtextbox"]

but, how can I set the value when sending form back to browser?

0
CodeDigger
12/19/2006 3:00:22 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

4 Replies
1047 Views

Similar Articles

[PageSpeed] 58
Get it on Google Play
Get it on Apple App Store

If it's not runat="server" then you'll have to emit javascript to set the value:

document.getElementById('manualtextbox').value = '<desired value>';

0
stiletto
12/19/2006 4:10:45 PM

add runat="sever" to the control

 <input id="manualtextbox" type="text" value="abc" name="manualtextbox" runat="server" />

then use the id from code behind to set the value

manualtextbox.value=manualtextbox

0
jessjing
12/20/2006 1:38:37 AM
Hi, 

you're right, I don't want to use runat=server.
Question: how can I directly set the value from the code behind page (c#)?
If I understood you right you are propsing to read value from page into input (type=text). Isn't there a way to manipulate generated webpage to directly provide value="jshadska" for input?
0
CodeDigger
12/20/2006 10:36:32 AM
I found a quick and dirty solution hope to hear from a better one. Here the quick and dirty one:

page (Literal.Mode has to be set to PassThrough):
-------------------------------------------------
'>
// Literal ID can have same value as  because literal control itself doesn't apear on page

code behind reading the value:
------------------------------
string s = Request.Params["manualtextbox"];  // read entered value

code behind setting the value:
------------------------------
string newValue = "codebehind provided value";
manualtextbox.Text = @" ";
manualtextbox.Mode = LiteralMode.PassThrough;
0
CodeDigger
12/20/2006 12:14:19 PM
Reply:

Similar Artilces:

Problem on setting to DropDownList Value="id" and Text="Name" by reading values from SQL...
Hi!Well, my problem is that i don't know how to set different values on a DropDownList. I have an DropDownList and an SqlDataSource. When the aspx page loads, i want the DropDownList to fill data from a table on my SQL Server. Especially, i want each row of the DropDownList to take the Value property from the "ID" cell of my SQL Table and to take the Text property from the "Name" cell of my same SQL Table.Now, with my solution, the DropDownList takes the value for its "Value" and "Text" properties only from my  "Name" cell of my same...

Setting value of <INPUT type="file"> programmatically
Is there any way to set the value of a INPUT type=file programmatically or is it read only? vFlyer Labs http://www.vflyerlabs.com vflyer wrote: >Is there any way to set the value of a INPUT type=file programmatically or is it read only? > > Setting the value of an input type=file requires the UniversalFileRead privilege. -- Warning: May contain traces of nuts. ...

postback is deleting contents of <INPUT id="btnUpload" type="button" value="Upload" runat="server">
The <INPUT id="btnUpload" type="button" value="Upload" runat="server"> does not hold its value when there is a postBack to the server. Is there a way around this. Cheers What do you mean? The button text goes blank? Or do you mean it doesn't register it having a value a page reload after it being clicked? BrianBrian"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4). I select the file i wish to upload, i ...

Programmatically Populating the "mail.settings" section of "system.net" in web.config
I am fully aware that the system.net section of web.config typically looks something like this:  <system.net>    <mailSettings>      <smtp from="noreply@sample.com">        <network host="smtp_server_address" userName="myUsername" password="myPassword" />      </smtp>    </mailSettings>  </system.net>If web.config is so populated then this info is used for sending e-mails generally and al...

browsing Page.Controls, and setting values to objects owning the "Text" property
Bonjour a tous, I want to browse mypage.Controls in order to change the values of each object owning the Text property i did this : foreach(Control mycontrol in mypage.Controls) { if (mycontrol.Controls!=null) foreach(Control subcontrol in mycontrol.Controls) { if ((subcontrol.GetType().GetProperty("Text")!=null) && (subcontrol.ID!=null)) { mypage.Response.Write(subcontrol.ID.ToString()); subcontrol.GetType().GetProperty("Text").SetValue(subcontrol,"something&qu...

Using Non Runat="server" inputs in user control not submitting in web form.
I have created a user control which contains a single input which is not runat="server". A link on the control allows javascript to create more input fields which are given a unique id. I have put the control in my aspx page and it works fine until i submit the form, when the next page as I expected only shows a single input for the control. However the request.form structure doesnt seem to have the values for any of the inputs. Is this because any input that is not runat="server" will not be passed on form submission? If this is the case how can I write a control that will allow the user ad...

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTg3MjQ" />
 Hi I am developig a website and when I try to see the page source in the explorer I have houndreds of lines about this:<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /><input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" /><input type="hidden" name="__VIEWSTATEFIELDCOUNT" id="__VIEWSTATEFIELDCOUNT" value="697" /><input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value=...

Extra <INPUT TYPE="hidden" NAME=".cgifields" VALUE="ACTION"> ?
I keep seeing these "extra" hidden fields in my source ... Does anyone know where/what/why they are being generated ? <INPUT TYPE="hidden" NAME=".cgifields" VALUE="ACTION"> John W Moon At 10:45 AM 06/21/2001 -0400, Moon, John wrote: >I keep seeing these "extra" hidden fields in my source ... > >Does anyone know where/what/why they are being generated ? > ><INPUT TYPE="hidden" NAME=".cgifields" VALUE="ACTION"> > If youre using the CGI.pm module, theres most lik...

RE: Extra <INPUT TYPE="hidden" NAME=".cgifields" VALUE="ACTION"> ?
> >>>>> "Curtis" == Curtis Poe <poec@yahoo.com> writes: > > Curtis> my $foo_count = scalar @{[param('foo')]}; > > That's nice, but I prefer: > > my $foo_count = () = param('foo'); > > Less typing, less work for the machine. Less noise. More magic, > though. Oops, arguable on that. :) > > -- > Randal L. Schwartz - Stonehenge Consulting Services, Inc. - Let me guess ... param('foo') is assigned to a list ... the list is assigned to $foo_count in a scalar cont...

RE: Extra <INPUT TYPE="hidden" NAME=".cgifields" VALUE="ACTION"> ?
Here the code (is this what you wanted ?) but from Mel's reply looks like the problem could be the "endform" use strict; use CGI qw(:standard :all *table); use vars qw($dbh $REQUEST) ; # global ! use DBI; use Cwd; my $CGI_HOME=cwd(); # get $home # use lib "/opt/common/html/actual/cgi-bin/Library"; use lib "Library"; require MyConnect; use MyCategories; # # (keywd,value) for estimates are: # FY=30-Jun-YYYY - The fiscal year of the Estimate # ACCT=varchar2(15) - Account to Input/View # CUST_ID=number(10) - C...

Re: Extra <INPUT TYPE="hidden" NAME=".cgifields" VALUE="ACTION"> ?
Mel Matsuoka wrote: : >Randal L. Schwartz wrote: : >: ... : >: Second might mean something like: : >: : >: $foo_length = SOME_LIST # although this can't happen : >: ========= list : >: = assigned to : >: =========== scalar : >: : >: See the difference? And the latter can't happen. : > : >Sure it can. Well, the list itself doesn't get assigned to the scalar, : >but an assignment does get made: The last element of SOME_LIST to : >$foo_length. So : > : >my $number_of_pe...

Problem with this <input type="Submit" name="Action" value="Enter information">
<input type="Submit" name="Action" value="Enter information"> I seem to have problem with my asp page once I changed the value from "Enter Information" to other word such as Submit or Update... etc... Why am I getting this error ? Does changing the value effect the asp page ? You may have some sort of back-end code that might be checking the value of the submit button before sending it for processing... hope this helps.Need ASP.NET web hosting? Private Message me for a free quote....

RE: Extra <INPUT TYPE="hidden" NAME=".cgifields" VALUE="ACTION"> ?
Yes, I assumed it is trying to help me ... But don't want it's (CGI's) help ... in this case Any one know how to stop it ... I do a $q->new CGI after getting my values from the post ; and yes I use $q->endform; John W Moon -----Original Message----- From: Mel Matsuoka [mailto:mel@hawaiianimage.com] Sent: June 21, 2001 00:53 To: beginners-cgi@perl.org Subject: Re: Extra <INPUT TYPE="hidden" NAME=".cgifields" VALUE="ACTION"> ? At 10:45 AM 06/21/2001 -0400, Moon, John wrote: >I keep seeing these...

Re: Extra <INPUT TYPE="hidden" NAME=".cgifields" VALUE="ACTION"> ?
Randal L. Schwartz wrote: : ... : Second might mean something like: : : $foo_length = SOME_LIST # although this can't happen : ========= list : = assigned to : =========== scalar : : See the difference? And the latter can't happen. Sure it can. Well, the list itself doesn't get assigned to the scalar, but an assignment does get made: The last element of SOME_LIST to $foo_length. So my $number_of_pets = ('dog','cat','iguana'); sets $number_of_pets to 'iguana'. -- tdk At 04:2...

Web resources about - setting non server control values: input type="text" how to set value programmatically? - asp.net.web-forms

Resources last updated: 1/15/2016 7:14:37 AM