Solved

User Control - runat="server"

Posted on 2014-09-18
6
164 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET Content Page 3 64
asp.net figure out error 3 45
ASP.net Will we ever be able to build mobile apps in it 6 115
Connect Gridview column to Textbox in C# 2 55
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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
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…

734 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