Re: How can I get the value from the client-side created element object?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Vidar Petursson (thekingYoUKnOwWhatToDoHEREeh_at_icysoft.com)
Date: 05/25/04


Date: Tue, 25 May 2004 15:42:14 -0000

Hi

Hmmm just tested it here and it worked perfectly, no problem getting
the data in input....

-- 
Best Regards
  Vidar Petursson
 ==============================
Microsoft Visual: Scripting MVP 2000-2004
http://www.icysoft.com/
http://www.deus-x.com/ Instant e-commerce
http://www.microsoft.com/technet/scriptcenter/
Playground: http://213.190.104.211/  ( IE 5.5+ only )
No matter where you go there you are
 ==============================
"Quentin Huo" <q.huo@manyworlds.com> wrote in message 
news:%23cAYjymQEHA.2784@TK2MSFTNGP10.phx.gbl...
> Hi:
>
> Unfortuately, it doesn't work. But anyway, thanks for you guys.
>
> So I am thinking another way to handle this: how can I create elements
> dynamically in server-side?
>
> I am trying to create a page for edit books' information. Some books have
> one author and some books have more than one authors. So, I want to give
> only one text box for the author name. And I will create a link saying 
> "more
> authors". When a book has two authors, click the "more authors" link and a
> new text box will be created in the server-side.
>
> I know I should create a method in the code-behind to handle the click 
> event
> for that link. But I want to know how to create an element ( such as input
> box) in the server-side?
>
> I tried to create a asp:label named "newAuthors" (ID) in the page, and  I
> create the new text box as:
>
> ......
>
> newAuthors.Text = "<input runat=server id=newAuthors name=newAuthors >";
>
> ......
>
> but if I put a name in this box and post the page, the name that I input
> cannot be shown in the box anymore (I think it is not in the VIEWSTATE). 
> So
> I think there should be another better way to create an element in 
> ASP.NET.
>
> Any better way?
>
> Thank you very much!
>
> Q.
>
>
>
>
> "Vidar Petursson" <thekingYoUKnOwWhatToDoHEREeh@icysoft.com> wrote in
> message news:%23Tu2yRjQEHA.3744@TK2MSFTNGP10.phx.gbl...
>> Hi
>>
>> This should work
>>
>> Client
>> var e = document.createElement("INPUT");
>> e.name = "theNAME"; // Name of element
>> document.forms["FORMNAME"].appendChild(e);
>>
>> Server
>> string sRes = (Request.Form["theNAME"] != null ) ?
>> Request.Form["theNAME"].ToString() : "";
>>
>> -- 
>> Best Regards
>>   Vidar Petursson
>>  ==============================
>> Microsoft Scripting MVP
>> http://www.microsoft.com/technet/scriptcenter
>>  ==============================
>> "Quentin Huo" <q.huo@manyworlds.com> wrote in message
>> news:eTjNQzeQEHA.964@TK2MSFTNGP10.phx.gbl...
>> > Hi:
>> >
>> > I created a web-form user control. And in client-site, there is a link
>> > which
>> > will create a Input element object when it is clicked.
>> >
>> > <script language=javascript>
>> >
>> > ......
>> > var nameInput = document.createElement("input");
>> > nameInput.setAttribute("id", "authorname");
>> > .....
>> >
>> > </script>
>> >
>> > But when click "save" button" on this page,  I can not get the value of
>> > the
>> > created element object in the user control by (in C#)
>> >
>> > ......
>> > string x=Request["authorname"];
>> > ......
>> >
>> > So how can I get the value from the client-side created element in a
> user
>> > control of ASP.NET?
>> >
>> > Thanks
>> >
>> > Q.
>> >
>> >
>> >
>> >
>>
>>
>
> 

Quantcast