?
Solved

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

Posted on 2004-09-27
5
Medium Priority
?
175 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

777 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