Solved

User Control - runat="server"

Posted on 2014-09-18
6
159 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 40

Accepted Solution

by:
Kyle Abrahams earned 333 total points
ID: 40330451
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
ID: 40330459
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 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 333 total points
ID: 40330473
Understood, but the page still needs to know that your control should be runat = server.  There's no way around that.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:HLRosenberger
ID: 40330642
ok.   thanks.
0
 
LVL 19

Assisted Solution

by:Manoj Patil
Manoj Patil earned 167 total points
ID: 40338405
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
ID: 40359754
thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

820 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