Re: setting a form control from javascript

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Greg Burns (greg_burns_at_DONT_SPAM_ME_hotmail.com)
Date: 07/24/04


Date: Sat, 24 Jul 2004 10:18:14 -0400

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:PlaceHolder ID="ph" Runat="server" />

Dim myInputHidden As New HtmlControls.HtmlInputHidden
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" <ajfish@blueyonder.co.uk> wrote in message
news:eNEJkiVcEHA.2324@TK2MSFTNGP10.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
>
>



Relevant Pages

  • Re: Usercontrol outputting html programmatically
    ... You would need to have some placeholder such as a <div>. ... able to write whatever HTML you want at that position. ... > of the page regardless of the postition of the user control. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: difference between htmlbutton and webcontrol button?
    ... easier to set-up and manipulate on the server site. ... old-school html elements that do everything on the client-side (though you ... that HtmlButton represents an HTML control which has API following closely ... E.g WebControls are more abstractions over the presentation ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Rendered web control using IPostBackEventHandler.RaisePostBackEvent
    ... thanks bill, i just sussed that out, but thanks - at least i know i've got ... when i perform a callback from an HTML control thats not a submit button, ... it's called when a submit html button submits the form, ... from an onclick event ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Pocket PC - HTML Control question.
    ... you may have to make your application resolution-aware. ... I have a dialog that has a HTML control. ... So I tried to use "DTM_ADDSTYLE" message to reduce the font size. ...
    (microsoft.public.pocketpc.developer)
  • dynamic html table with textboxes
    ... In my webpage I have a PlaceHolder. ... generated html table is added to this PlaceHolder: ... If the user enter some text in the textbox and click ... Also the user input is lost. ...
    (microsoft.public.dotnet.framework.aspnet)