2 Replies - 2509 Views - Last Post: 07 August 2008 - 12:17 AM

#1 Footsie  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 24
  • View blog
  • Posts: 370
  • Joined: 20-September 07

Changing form to user Control

Post icon  Posted 05 August 2008 - 03:58 AM

I created a web form called JarControl.aspx and then tried to convert it to become a user control, JarControl.ascx
Attached Image

As you can see in my pic, I have changed all the extensions to ascx
And I have changed the code behind file to inherit from System.Web.UI.UserControl.
Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class JarControl : System.Web.UI.UserControl
{
	protected void Page_Load(object sender, EventArgs e)
	{

	}
}



It still gives me that annoying red underline (see pic) and Validation errors such as:
Validation (ASP.Net): Attribute 'Control' is not a valid attribute of element 'Page'.

I've tried saving and building the project a few times - doesn't get rid of it.

Is This A Good Question/Topic? 0
  • +

Replies To: Changing form to user Control

#2 Bardy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 30-July 08

Re: Changing form to user Control

Posted 06 August 2008 - 01:00 AM

Why not just create a new UserControl, then dump everything in JarControl into the usercontrol. Copy all the stuff in the body of the aspx page to asxc, and everything under PageEvent in aspx.cs to the ascx.cs.

Thats should sort out your problem.
Was This Post Helpful? 0
  • +
  • -

#3 Footsie  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 24
  • View blog
  • Posts: 370
  • Joined: 20-September 07

Re: Changing form to user Control

Posted 07 August 2008 - 12:17 AM

Thanks Bardy.

I realise that that would probably fix the problem, but I was following an exercise in a book that indicated that there should be no problem doing the conversion. Thing is, the control works perfectly, I used it in another web form. It's just the Visual Studio validation that seems to be glitchy.

EDIT:
After closing everything down and re-opening Visual Studio and the project the errors seem to have disappeared.

This post has been edited by Footsie: 07 August 2008 - 01:26 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1