473,326 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

dynamic form generation -> problem

Hello,

After trying some ways to do it I wanted to use something like the code
below but for some reason
is not working (I have to generate the entire form dynamically (not only the
controls)):
Can anyone make any suggestions on how to do it ?

Thanks

----------------------------------------------------------------------------
dim myPlaceHolder as new PlaceHolder
dim btn1 as new Button
dim btn2 as new Button

btn1.Text = "btn 1"
btn2.Text = "btn 2"

myPlaceHolder.Controls.Add(New LiteralControl("<form name='myForm'
runat='server' method='GET'>"))
myPlaceHolder.Controls.Add(btn1)
myPlaceHolder.Controls.Add(btn2)
myPlaceHolder.Controls.Add(New LiteralControl("</form>"))

--------------HTML SECTION------------------------------------------
NOT WORKING

<td><asp:placeholder id=myPlaceHolder runat=server></asp:placeholder></td>
----------------------------------------------------------------------------
WORKS (but is not what I need)
----------------------------------------------------------------------------
<td>
<form runat=server>
<asp:placeholder id=myPlaceHolder runat=server></asp:placeholder>
</form>
</td>
----------------------------------------------------------------------------



================================================== ==================
"Venus" <so**@gal.net> wrote in message
news:bTCNc.122869$eO.114936@edtnps89...
Hello,

Thanks for your reply.
I understand that a control can be created dynamically in several ways:
1) using StringBuilder
2) using Controls.Add
3) using ASP PlaceHolder

But this is just for the controls and not for the form itself.
What I am trying to achieve is to create an entire form (including controls) dynamically and place it in HTML when needed.
So my next question would be how to do this ? In other words how to place
the control elements in the dynamic form ?
Assuming of course that the controls have been generated using one of the
above methods.

strForm = "<form name=""someName"" method= .....>"
----------------------------------------------------------
how to place the elements inside the form ???
----------------------------------------------------------
strForm += "</form>"
================================================== =======
and now place it in HTML

<td><%=strForm %> </td>
================================================== =======

Thanks
"SMG" <SM*@nodmain.com> wrote in message
news:OS**************@TK2MSFTNGP09.phx.gbl...
Dear Vinus,

Here is the Code:::: ( You can copy paste the below given code in
page_Load )
StringBuilder strBuild= new StringBuilder();
strBuild.Append("<asp:Label id=one ");
strBuild.Append(" runat=server>Hello!!! Can you see me");
strBuild.Append("</asp:Label>");
Page.Controls.Add( Page.ParseControl(strBuild.ToString()));

// Second Way of Coding... Create Your Control on the Fly

Label lblName = new Label();
lblName.ID = "NewID";
lblName.Text = "My New Label to display ";
Page.Controls.Add(lblName);

Regards,
Shailesh MG
"Venus" <so**@gal.net> wrote in message
news:WbmNc.103175$Rf.2421@edtnps84...
Hello,

I am trying to generate a dynamic form at runtime and would like to do it using "<asp: ..." form elements as follows

Build up the string that is placed somewhere in the HTML code the same way like regular input fields can.

strForm = "<form name=""myForm"" runat=""server"">" & vbCrLf
strForm += "<asp:button name=""myName"" .... runat=""server"" />" & vbCrLf strForm += "<asp:button ....... runat=""server"" />" & vbCrLf
strForm += "</form>" & vbCrLf

--

The problem this code is placed as a string "ad literam" without

generating
the elements.
If I would use normal input fields this works fine but would like to
use
ASP
controls if possible.
Is there a way to do what I am trying to do here ?

I don't want to do the code generation in the HTML section by mixing

HTML with VB code
<% If something %>
<asp:button name= ... />
<% Else %>
.....



Nov 18 '05 #1
0 1435

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tim Pascoe | last post by:
I am using ASP to dynamically generate a series of forms. When the page is loaded, everything appears to be correct, except that the first form generated fails with a "FormName is Null or not an...
6
by: alexandre damiron | last post by:
Did anyone tried dynamic variable naming in Js, like the ${$varname} feature of PHP ? It would easier a long DOM generation, for example to place such a code portion into a loop .... ...
11
by: Marco Loskamp | last post by:
Dear list, I'm trying to dynamically generate functions; it seems that what I really want is beyond C itself, but I'd like to be confirmed here. In the minimal example below, I'd like to...
10
by: Mark Winter | last post by:
Hello, I am wondering if someone could point me in the right direction to figure out how to create a dynamic form. I have been developing programs in perl and oracle and have recently switched...
15
by: Nospam | last post by:
Is there a tutorial on dynamic SID generation?
3
by: RahimAsif | last post by:
I am writing an application that requires the a portion of the main menu to be dynamic. The menu has file, panels, view files and help across the top. The view files sub menu needs to be...
5
by: pittendrigh | last post by:
There must be millions of dynamically generated html pages out there now, built by on-the-fly php code (and jsp, perl cgi, asp, etc). Programatic page generation is transparently useful. But...
3
by: fedya | last post by:
I am trying to have the last 12 months to always be the option in the dropdown for a combo box. (Basically a combobox, with dynamic options) I am using Access 2000. What is the function and...
0
by: windx | last post by:
I want to generate the field elements in the form dynamically by using the data retrived from the database.so i think that generating dynamic form bean using the values from the database.what would...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.