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
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