Solved

User Control - runat="server"

Posted on 2014-09-18
6
146 Views
Last Modified: 2014-10-03
I created a user control.   When I drop it on the page, it tells me it needs the runat="server" attribute.  How can I code the control itself so it has runat="server"?
0
Comment
Question by:HLRosenberger
  • 3
  • 2
6 Comments
 
LVL 39

Accepted Solution

by:
Kyle Abrahams earned 333 total points
Comment Utility
A user control is a module that you drop on another page.

When you register the control on the page and create an instance of that control, you have to tell the page to run the instance at the server.

There's no way I know of to get around putting in runat="server".  What are you trying to accomplish by not having it there?
0
 
LVL 1

Author Comment

by:HLRosenberger
Comment Utility
I do want it there.  I just was hoping to not have to add it when I put it on the page, but instead code it right within the control. This is my own control I have written, not a third party thing.
0
 
LVL 39

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 333 total points
Comment Utility
Understood, but the page still needs to know that your control should be runat = server.  There's no way around that.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 1

Author Comment

by:HLRosenberger
Comment Utility
ok.   thanks.
0
 
LVL 19

Assisted Solution

by:Manoj Patil
Manoj Patil earned 167 total points
Comment Utility
Hey its not possible to use the user control without runat=server
Because these controls are derived from System.Web.UI.UserControl class
And if you remove the runat=server property then it gives you only warning but it will not be rendered on the page.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
Comment Utility
thanks
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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