Solved

User Control - runat="server"

Posted on 2014-09-18
6
167 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
[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
  • 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
Technology Partners: 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!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

724 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