Solved

Usercontrol: Where to have Form, in usercontrol or normal.aspx file.??

Posted on 2004-09-27
5
171 Views
Last Modified: 2010-04-15
Hi there,

I have designed a usercontrol which basically holds some graphics and a Menu bar....

I then place this usercontrol into my various aspx pages...

question is... the webform <form>... where should it go, in the usercontrol and in the aspx??

Would it bee problem if it was also in the usercontrol, does it merge or support some kind of inheritence??

Ideas?? thanks


Ian
0
Comment
Question by:ianinspain
  • 2
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
Rodney Helsens earned 250 total points
ID: 12163279
My suggestion is to put your <form runat="server"> in your aspx pages, make your user controls without form tags... there will be problems if there are multiple forms with the runat="server" attribute, only one per page ,you can have multiple forms per page but only one with the runat="server" attribute.

any user control loaded into the page will be a child of its parent page and accessible as such.
0
 
LVL 13

Assisted Solution

by:dungla
dungla earned 250 total points
ID: 12166487
rodnex was right, you should make your user controls without form tags. The form tags should place in aspx file. When you place your usercontrol into an aspx file, mannually declare your usercontrol in associated aspx.cs file, then you can handle your usercontrol.

For example, i have usercontrol name MyUserControl.ascx and aspx file name MyFile.aspx. MyFile.aspx should have <form runat="server">, MyUserControl without form tags. When using drag & drop MyUserControl to MyFile.aspx, automatically the name of it will be MyUserControl1, then go to MyFile.aspx.cs declare a new variable (protected, private, public...) MyUserControl MyUserControl1;

And then you can handle MyUserControl via MyUserControl1 instance

Hope this help
0
 

Author Comment

by:ianinspain
ID: 12167220
Hi .. thanks everyone for there comments...

I suppose there is no special way of removing the form??

Just goto into the html and remove the <form> tags??

or is there an automatic wya orsomething?

Ian
0
 
LVL 9

Expert Comment

by:Rodney Helsens
ID: 12168891
There is nothing special about the tag, you can just remove the opening <form> and closing </form> tags and from the html.

If by 'automatic way', you mean some way to help you remove the tags... most IDE's have a find/replace feature, you can do mass find/replace on to locate/replace all the form tags from a project or folder, hope that helps.


0
 

Author Comment

by:ianinspain
ID: 12169086
thanks ... split points between the 2 helpers..thought this was fair....

Again.. thanks both..

Ian
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question