TagPrefix is not recognized

A

ahuja.madhur

Hello

I am creating a ASP.net 2.0 webpart for use in an aspx just for
learning purpose.
My webpart code is very simple :

Now when I use this webpart DLL as a reference in website project and
include this line

<%@ Register TagPrefix="custom" Namespace="aspwebpart" %>

The custom keywork is not usable inside the aspx page.
These lines throw the error that FeaturePart is not recognized
<WebPartsTemplate>

<custom:FeaturePart ID="my" Runat="Server" />
</WebPartsTemplate>

Any Ideas??

===========================================================

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;

namespace aspwebpart
{

public class FeaturePart:WebPart
{
const string str =
"server=10.111.121.24;Trusted_Connection=true;Database=NorthWind";
const string query = "Select * from products";

public FeaturePart()
{
this.Title = "Feature Part";
}

protected override void RenderContents(HtmlTextWriter writer)
{

DataTable pt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(query, str);
da.Fill(pt);
Random rnd = new Random();
DataRow row = pt.Rows[rnd.Next(pt.Rows.Count)];

writer.Write((string)row["ProductName"]);
writer.Write(string.Format("-{0:c}", row["UnitPrice"]));

base.RenderContents(writer);
}

}
}

Regards

Madhur
 
G

Guest

Madhur,

Check out my post "Error creating control..Server tag error" from earlier in
the day. I had this error with a custom control. Don't know if the same
applies to webparts but you may need to add the "assembly=" attribute. See
my sample code and resolution in the posts. Dave
 
A

ahuja.madhur

Hi Dave

Gr8 !!! That did the trick. Thanks very much
Clear me one thing, what does Assembly attribute refers to?
Does it refer dll file name or Assembly is an attribute stored inside
..NET metadata.

I am asking it because when I appended .dll in front of it, it again
gave the same error.

Madhur

Madhur,

Check out my post "Error creating control..Server tag error" from earlier in
the day. I had this error with a custom control. Don't know if the same
applies to webparts but you may need to add the "assembly=" attribute. See
my sample code and resolution in the posts. Dave

Hello

I am creating a ASP.net 2.0 webpart for use in an aspx just for
learning purpose.
My webpart code is very simple :

Now when I use this webpart DLL as a reference in website project and
include this line

<%@ Register TagPrefix="custom" Namespace="aspwebpart" %>

The custom keywork is not usable inside the aspx page.
These lines throw the error that FeaturePart is not recognized
<WebPartsTemplate>

<custom:FeaturePart ID="my" Runat="Server" />
</WebPartsTemplate>

Any Ideas??

===========================================================

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;

namespace aspwebpart
{

public class FeaturePart:WebPart
{
const string str =
"server=10.111.121.24;Trusted_Connection=true;Database=NorthWind";
const string query = "Select * from products";

public FeaturePart()
{
this.Title = "Feature Part";
}

protected override void RenderContents(HtmlTextWriter writer)
{

DataTable pt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(query, str);
da.Fill(pt);
Random rnd = new Random();
DataRow row = pt.Rows[rnd.Next(pt.Rows.Count)];

writer.Write((string)row["ProductName"]);
writer.Write(string.Format("-{0:c}", row["UnitPrice"]));

base.RenderContents(writer);
}

}
}

Regards

Madhur
 
G

Guest

Madhur,

The assembly name refers to the project that contains my custom controls.
In my case my project name was CustomControls, so when I compile it becomes
CustomControls.dll. The assembly attribute must then match the name of the
dll..."Assembly="CustomControls" without the .dll extension though..go figure.

Hi Dave

Gr8 !!! That did the trick. Thanks very much
Clear me one thing, what does Assembly attribute refers to?
Does it refer dll file name or Assembly is an attribute stored inside
..NET metadata.

I am asking it because when I appended .dll in front of it, it again
gave the same error.

Madhur

Madhur,

Check out my post "Error creating control..Server tag error" from earlier in
the day. I had this error with a custom control. Don't know if the same
applies to webparts but you may need to add the "assembly=" attribute. See
my sample code and resolution in the posts. Dave

Hello

I am creating a ASP.net 2.0 webpart for use in an aspx just for
learning purpose.
My webpart code is very simple :

Now when I use this webpart DLL as a reference in website project and
include this line

<%@ Register TagPrefix="custom" Namespace="aspwebpart" %>

The custom keywork is not usable inside the aspx page.
These lines throw the error that FeaturePart is not recognized
<WebPartsTemplate>

<custom:FeaturePart ID="my" Runat="Server" />
</WebPartsTemplate>

Any Ideas??

===========================================================

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;

namespace aspwebpart
{

public class FeaturePart:WebPart
{
const string str =
"server=10.111.121.24;Trusted_Connection=true;Database=NorthWind";
const string query = "Select * from products";

public FeaturePart()
{
this.Title = "Feature Part";
}

protected override void RenderContents(HtmlTextWriter writer)
{

DataTable pt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(query, str);
da.Fill(pt);
Random rnd = new Random();
DataRow row = pt.Rows[rnd.Next(pt.Rows.Count)];

writer.Write((string)row["ProductName"]);
writer.Write(string.Format("-{0:c}", row["UnitPrice"]));

base.RenderContents(writer);
}

}
}

Regards

Madhur
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top