Hi,
I want to generate a value with javascript and include it in the form
postback for a web form.
based on my previous web development experience, I think I need an <input
type=hidden> on the page. However, to fit in properly with the web forms
paradigm, I would like this to be a proper asp.net server side control
rather than just generating it in the HTML.
I have found I can do this OK with a text box as long as it's visible; if I
make the text box hidden it is no longer rendered in the HTML (and so i
can't set it from javascript). What's the best way to achieve what I'm
trying to do?
Andy 3 1267
Can't you just add a runat=server and an id to the HTML control?
<input type="hidden" runat="server" id="id1">
OR generate it at run-time using a PlaceHolder:
<asp:PlaceHolde r ID="ph" Runat="server" />
Dim myInputHidden As New HtmlControls.Ht mlInputHidden
ph.Controls.Add (myInputHidden)
Not sure what you gain by using the placeholder method though. Escepcially
because the ClientID would not be known at design time for use with your js
code.
Greg
"Andy Fish" <aj****@blueyon der.co.uk> wrote in message
news:eN******** ******@TK2MSFTN GP10.phx.gbl... Hi,
I want to generate a value with javascript and include it in the form postback for a web form.
based on my previous web development experience, I think I need an <input type=hidden> on the page. However, to fit in properly with the web forms paradigm, I would like this to be a proper asp.net server side control rather than just generating it in the HTML.
I have found I can do this OK with a text box as long as it's visible; if
I make the text box hidden it is no longer rendered in the HTML (and so i can't set it from javascript). What's the best way to achieve what I'm trying to do?
Andy
"Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message
news:Oj******** ******@TK2MSFTN GP10.phx.gbl... Can't you just add a runat=server and an id to the HTML control?
<input type="hidden" runat="server" id="id1">
thanks, I didn't realise you could do this.
I'm a bit new to web forms and I thought you had to put the controls on in
designer mode for them to be accessible as controls on the server
Andy
OR generate it at run-time using a PlaceHolder:
<asp:PlaceHolde r ID="ph" Runat="server" />
Dim myInputHidden As New HtmlControls.Ht mlInputHidden ph.Controls.Add (myInputHidden)
Not sure what you gain by using the placeholder method though. Escepcially because the ClientID would not be known at design time for use with your
js code.
Greg
"Andy Fish" <aj****@blueyon der.co.uk> wrote in message news:eN******** ******@TK2MSFTN GP10.phx.gbl... Hi,
I want to generate a value with javascript and include it in the form postback for a web form.
based on my previous web development experience, I think I need an
<input type=hidden> on the page. However, to fit in properly with the web forms paradigm, I would like this to be a proper asp.net server side control rather than just generating it in the HTML.
I have found I can do this OK with a text box as long as it's visible;
if I make the text box hidden it is no longer rendered in the HTML (and so i can't set it from javascript). What's the best way to achieve what I'm trying to do?
Andy
"Andy Fish" <aj****@blueyon der.co.uk> wrote in message
news:OK******** ******@TK2MSFTN GP10.phx.gbl... thanks, I didn't realise you could do this.
I'm a bit new to web forms and I thought you had to put the controls on in designer mode for them to be accessible as controls on the server
ah, now I look a bit closer, I see you can switch the toolbox to insert HTML
elements as well as webforms controls. slowly I'm getting the hang of it.
:-) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Amir Eshterayeh |
last post by:
Dear Friends
Hope things goes well to you. I have this problem. Would you please give me
your solution?
I want to change a property that I define on my user control in my web form
that contains that user control.
but when I want to set the property of user control at my web form, got this
error
c:\inetpub\wwwroot\test4\WebForm1.aspx.vb(19): Name 'Uc1' is not declared.
How can I solve this problem. Please help.
|
by: daniel kaplan |
last post by:
Hi All,
Been learning Javascript (via google) to create forms with pre-set values.
As seen below. My problem I have found is this: I can't seem to figure out
(or find so far via google) how to preset form options when the input type
is a radio button, or dropdown list. The same method does not seem to work
with input fields.
Anyone know of such a comprehensive site?
|
by: Bob |
last post by:
I'm a total newbie at Javascript, but a programmer for over 20 years...
so, my plans may be bigger than they are possible.
I'm trying to set with Javascript the value of a form field... easy
enough, right?
e.g. this successfully sets the local form's field:
document.thetestform.mycity.value='paris';
|
by: Mike |
last post by:
Hi,
I am developing a JavaScript calendar control. I want my user control to
expose a property that returns the value of the selected calendar date. I
have an "input" control that displays the selected date. I also tried to add
a Label server-side control, but I am unable to set its value through
Javascript.
<form id="mainForm" name="mainForm" action="" method="post">
<p>
|
by: CLEAR-RCIC |
last post by:
Hi,
I'm having problems setting focus to a textbox on a web user contol on an
asp.net web page. The following script works on normal asp.net pages:
<script language="javascript">
function cmdButton1_Clicked()
{ document.all('txtInput1').focus();
return false;
}
| |
by: Andre Ranieri |
last post by:
I'm trying to create a login page for customers to log into our corporate
website, our presidents naturally wants the user and password fields to
populate from a cookie so the customer doesn't have to type their credentials
every time, this seems like a pretty common thing. However, when I try to
populate the password HTML textbox from the cookie, the textbox remains
blank. However, if I try this from an equivalent web control, the...
|
by: Glenn T. Kitchen |
last post by:
Hello All,
Does anyone know how to set the focus to a textbox control on Page_Load?
Thank you,
Glenn
|
by: Sridhar |
last post by:
Hi,
I have a question. I have created a user control which contains a
textbox and a button. we will enter some search word in the textbox and hit
the button. Then we will get a pop-up with the listbox that contains the
matches. Once I select one of the matches, it will close the pop-up and
display the selected one in a label control which is also in the user
control. Everything is working fine. But I am not getting one thing. After
the...
|
by: Efi Merdler |
last post by:
Hi,
In my code I'm doing some xml transformation, at the end I receive a
fully transformed html file.
I'm setting the Value property of an hidden field control to have the
content of this html file.
In the debugger I can see that the control contains the value
correctly, however when the page is displayed in a browser all <
symbols are replaced by < .
|
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...
|
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...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |