Asp.net Unknown Server flag Error

Source: Internet
Author: User

When you write a custom control, register it on the page, and try again on the page, you can see the effect normally. However, when you execute this page, an error is reported, Unknown Server tag, I checked it online and found it on the web. add a paragraph in config

Custom Controls

Code

Namespace puretest
{
[Toolboxdata ("<{0}: pager runat = Server> </{0}: pager>")]
Public class Pager: Control
{
Public int currentpage
{
Get; set;
}

Public int pagesize
{
Get; set;
}

Public int totalcount
{
Get; set;
}

// Hack: the URL condition for paging should be included here
Protected override void render (htmltextwriter writer)
{
Base. Render (writer );
// Var first = currentpage-5;
// Var end = currentpage + 5;
// Var totalpage = getpagecount ();
// If (first <1)
//{
// First = 1;
//}
// If (end> totalpage)
//{
// End = totalpage;
//}
// Var sb = new stringbuilder ();
// Sb. append ("<Div id = 'pager'> ");
// For (VAR I = first; I <end; I ++)
//{
// If (I = currentpage)
//{
// Sb. appendformat ("<strong> {0} </strong>", I );
//}
// Else
//{
// Sb. appendformat ("<a href0000'{0}.html '>{0} </a>", I );
//}
//}
// Sb. append ("</div> ");
// Writer. Write (sb. tostring ());
Writer. Write ("My first control ");
}

Private int getpagecount ()
{
Return pagesize = 0? 0: (totalcount + pagesize-1)/pagesize;
}
}
}

 

 

Page

 

Code

<% @ Page Language = "C #" autoeventwireup = "true" codebehind = "default. aspx. cs" inherits = "puretest. _ default" %>
<% @ Register tagprefix = "MC" namespace = "puretest" %>

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Div style = 'height: 30px; '> </div>
<MC: pager runat = "server"> </MC: pager>
</Div>
</Form>
</Body>
</Html>

 

 

Web. config

 

Code

<Pages>
<Controls>
<Add tagprefix = "asp" namespace = "system. Web. UI" assembly = "system. Web. Extensions, version = 3.5.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35"/>
<Add tagprefix = "asp" namespace = "system. web. UI. webcontrols "assembly =" system. web. extensions, version = 3.5.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35 "/>
<Add tagprefix = "MC" namespace = "puretest" assembly = "puretest"/>
</Controls>
</Pages>

 

 

Reference link:

Http://blog.sina.com.cn/s/blog_55e42da60100i1t6.html

Http://forums.asp.net/t/1337638.aspx

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.