CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

MS SQL 2008 on ASP.NET Hosting



Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 10/13/2003 3:37:38 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 7 Views: 52 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
8 Items, 1 Pages 1 |< << Go >> >|
sansti
Asp.Net User
How to add &quot;&lt;form runat=server&gt;&quot; programmatically ?10/13/2003 3:37:38 PM

0/0

Hi.

I'm creating a custom webcontrol. The control should be able to recive usercontrols and place them in a "html-template". In your page you should be able to send in a usercontrol (ascx-file) and my webcontol will place it in a predefined htmltable.

Feks. (in codebehind.vb)

Dim myUserControl as Control = LoadControl("/myUserControl.ascx")
Dim a as new ns.TemplateControl()
a.title = "This is the title of the page"
a.keywords = "Keywords, key, words"
a.AddControlToRightMenu(myUserControl) 'Send control to the template

The control will generate the following html to the client:

<html>
<head>
<title>This is the title of the page</title>
<meta name="keywords" value="Keywords, key, words">
</head>
<body>

<!--myUserControl.ascx-->
<input type="text" id="txtName">
<input type="button" value="Click me!">
<!--end myUserControlascx-->

</body>
</html>

Of course this won't work without any <form> tags!
But I want to add this form tags in the webcontrol. The webcontrol use the render-method to generate the "template". And the form tag have to "runat=server". If not the usercontrols added won't work. (because the usercontrols have ex. <asp:Button>, and then : "Control '_ctl0_Button1' of type 'Button' must be placed inside a form tag with runat=server")

But i can't use this code in my webcontrol:
output.AddAttribute("runat", "server")
output.RenderBeginTag(HtmlTextWriterTag.Form)
output.RenderEndTag()

So how can i add <form runat="server"> programmatically ??


regards,
Stian
joteke
Asp.Net User
Re: How to add &amp;quot;&amp;lt;form runat=server&amp;gt;&amp;quot; programmatically ?10/13/2003 4:40:07 PM

0/0

Hmm, I think you would need to create a HtmlForm (System.Web.UI.HtmlControls namespace) instance and add it as child control and then wrap things that way. Though why can't the Page have the form? It might save you from other extra troubles.
Thanks,

Teemu Keiski
Finland, EU
Andy Smith
Asp.Net User
Re: How to add &quot;&lt;form runat=server&gt;&quot; programmatically ?10/13/2003 4:42:15 PM

0/0

As a direct answer to your question, you'll have to create a control of type System.Web.UI.HtmlControls.HtmlForm, add it to the control hierarchy, and let it render itself.

at a higher level... it looks like you want to do page level templating. In that case, instead of rolling your own, I suggest you take a look at the various Master Pages implementations
phishstick40
Asp.Net User
Re: How to add &quot;&lt;form runat=server&gt;&quot; programmatically ?10/14/2003 1:31:18 PM

0/0

Public Overridable Sub VerifyRenderingInServerForm(ByVal control As System.Web.UI.Control)

Member of: System.Web.UI.Page

usage:
Me.Page.VerifyRenderingInServerForm(myControl)
Andy Smith
Asp.Net User
Re: How to add &quot;&lt;form runat=server&gt;&quot; programmatically ?10/14/2003 5:25:34 PM

0/0

VerifyRenderingInServerForm is a helper method that throws an exception if the control is not contained by a form. It does not create a form if one does not exist.
phishstick40
Asp.Net User
Re: How to add &quot;&lt;form runat=server&gt;&quot; programmatically ?10/14/2003 8:09:32 PM

0/0

thanks andy. i've never used it, but i thought it may help here.

it throws an exception??? wouldn't a boolean function be nicer to program with??

If Not Me.Page.IsInServerForm(ctl) Then
'add form here
End If
Andy Smith
Asp.Net User
Re: How to add &quot;&lt;form runat=server&gt;&quot; programmatically ?10/14/2003 8:20:12 PM

0/0

It is not meant to be used like that. It is meant for control developers to ensure that their control is part of a form. For instance, the TextBox control calls it during PreRender, as it's fairly useless to have a textbox that isn't in a form. The exception is meant to be bubbled up to the page, so the page developer will know that a control he is using requires to be inside a form.
phishstick40
Asp.Net User
Re: How to add &quot;&lt;form runat=server&gt;&quot; programmatically ?10/14/2003 8:35:15 PM

0/0

i see - makes perfect sense. thanks for the knowledge.
8 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Awesome ASP.NET 2.0 RSS Tool-Kit Released - ScottGu's Blog Add(. new Sample5Item("Scenario3",. "Consuming RSS feed programmatically using ..... NET 2.0 is support for a &lt;head runat="server"&gt;. ...
howtopreventcrosssitescripting | Channel 9 Replace("&lt;/i&gt;", ""); [Response.Write(sb.ToString());] }
[Wrox Professional ASP NET 2 0 XML Jan 2006 XML predefines the following entities: Symbol < > & ' '' Corresponding Entity lt gt amp apos quot Using the entity references, you can alternatively define ...
Peter Seale's weblog - SharePoint | PowerShell | Awesomeness Warm up the app pool by programmatically visiting a page in the site. ...... Yes , I can't help myself when describing PowerShell and say the quote in full, ...
Sun Java System Identity Manager 7.0 Workflows, Forms, and Views You can customize End User Menu Form to add links to launch special ...... single quotes to surround attribute values. If single quotes appear within the ...
An Introduction to the Source Code of the Pyrrho DBMS The double quotes are needed since YEAR is a reserved word in SQL2003. ...... to construct this programmatically, e.g. in the Page_load event, using Server. ...
cXML User’s Guide &quot;&amp;&lt;>&gt;'>&#174;&#xAE;'&apos; ...... script language=JScript RUNAT=Server>. function elementValue(xml, elem) ...
New Functionality in Sybase® Adaptive Server™ Enterprise 11.9.2 New Functionality in Adaptive Server Enterprise 11.9.2. 8-35. Adaptive Server Enterprise Version 11.9.2. Character Data Containing Quotation Marks ...
FME Fundamentals PythonFactory. • @SearchList. • @Tcl2. The encoding method is inspired by XML character entities. Symbol. Replaced with. <. . > . " ...
PmWiki | Cookbook / WikiSh INT1 -eq INT2; INT1 -ne INT2; INT1 -lt INT2; INT1 -le INT2; INT1 -gt INT2 ..... Also fixed a quoting problem within wikish when the quotes came from the ...




Search This Site:










label color problem

composite/template control

asp.net components......question

asp.net web dialog using c#

mps versioning clarification

building server controls in whidbey?

about html body tag problem..when building controls

nesting user controls with codebehind (jscript.net)

setting an imagebutton to use an embedded resource image

listbox view text by index

anyone written their own menu control in vb.net ?

progress bar with httphandler

web hosting

ghosting error with user controls

issue with validators as child controls

validating text box

i am trying to render some html/gif during validatinsummary rendering?

dataset lost at rendering time

host has locked down bin folder??

embedded resource: retrieving image from assembly

server intellect

how to scroll to a value in listbox without highlighting it

document properties in sql show like outlook.

composite control: controls collection of child control is cleared during page execution cycle

__dopostback

state management in collection property

control overrides page

need help to run online

asp.net treeview control

displaying a uri in the property grid

  Privacy | Contact Us
All Times Are GMT