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
<%@dotnet.itags.org. 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;Datab ase=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
MadhurMadhur,
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
"ahuja.madhur@.gmail.com" wrote:
Quote:
Originally Posted by
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;Datab ase=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
>
>
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
Dave wrote:
Quote:
Originally Posted by
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
>
"ahuja.madhur@.gmail.com" wrote:
>
Quote:
Originally Posted by
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;Datab ase=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
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.
"ahuja.madhur@.gmail.com" wrote:
Quote:
Originally Posted by
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
>
>
Dave wrote:
>
Quote:
Originally Posted by
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
"ahuja.madhur@.gmail.com" wrote:
Quote:
Originally Posted by
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;Datab ase=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
>
>
>
>
0 comments:
Post a Comment