Solved

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

Posted on 2004-09-27
5
173 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 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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