Solved

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

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Windows phone Development 11 29
Unit testing, moq, best practices 7 29
c# code 19 61
Check my code out(2) 1 35
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now