473,583 Members | 3,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.C ontrols.Add(New LiteralControl( "<form name='myForm'
runat='server' method='GET'>") )
myPlaceHolder.C ontrols.Add(btn 1)
myPlaceHolder.C ontrols.Add(btn 2)
myPlaceHolder.C ontrols.Add(New LiteralControl( "</form>"))

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

<td><asp:placeh older id=myPlaceHolde r runat=server></asp:placeholder ></td>
----------------------------------------------------------------------------
WORKS (but is not what I need)
----------------------------------------------------------------------------
<td>
<form runat=server>
<asp:placeholde r id=myPlaceHolde r runat=server></asp:placeholder >
</form>
</td>
----------------------------------------------------------------------------



=============== =============== =============== =============== ========
"Venus" <so**@gal.net > wrote in message
news:bTCNc.1228 69$eO.114936@ed tnps89...
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><%=strFor m %> </td>
=============== =============== =============== ============

Thanks
"SMG" <SM*@nodmain.co m> wrote in message
news:OS******** ******@TK2MSFTN GP09.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>He llo!!! Can you see me");
strBuild.Append ("</asp:Label>");
Page.Controls.A dd( Page.ParseContr ol(strBuild.ToS tring()));

// 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.A dd(lblName);

Regards,
Shailesh MG
"Venus" <so**@gal.net > wrote in message
news:WbmNc.1031 75$Rf.2421@edtn ps84...
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:butto n name=""myName"" .... runat=""server" " />" & vbCrLf strForm += "<asp:butto n ....... 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 1480

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

Similar topics

4
2159
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 Object" error. Each subsuquent form created by the code after that works perfectly. Why is it that the first form, generated with exactly the same...
6
4600
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 .... editSelectFontOption1 = document.createElement("OPTION"); editSelectFontOption1.setAttribute("value", "Font", 0); editSelectFontOption1Text =...
11
4715
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 create content to put at the address pointed to by f. In particular, I'd like to avoid/replace the memcpy line. Possible application (inspired by Paul...
10
4951
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 to php. I need to create a form that has four of five seperate pick list on it. Each item in each of the pick list depend on the users previous...
15
2053
by: Nospam | last post by:
Is there a tutorial on dynamic SID generation?
3
4776
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 dynamically generated, and the dynamic generation needs to occur right when the user selects this menu item (that is on the Popup event handler). However,...
5
3154
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 querying a database, negotiatinig lots of if-then-else logic and echo'ing html code out on port 80 every time a page is requested has to be a huge...
3
3207
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 syntax in visual basic to edit a combobox? I can do all the dynamic month generation, but I do not know how to edit a combobox from VB. Thank you.
0
1044
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 be your suggestion.I can i achive that.
0
7824
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8176
Oralloy
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. ...
0
8321
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7931
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...
0
6578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5699
isladogs
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...
0
5370
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...
0
3816
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...
1
1426
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.