Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-09-27
5
Medium Priority
?
177 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
Rodney Helsens earned 1000 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 1000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

610 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