User Control-Rewrite HTML code

Source: Internet
Author: User

# Region parameter attributes

// Arrangement
Int m_type = 0;
Public int type
{
Get {return m_type ;}
Set {m_type = value ;}
}

// Product category
Int m_productclass =-1;
Public int productclass
{
Get {return m_productclass ;}
Set {m_productclass = value ;}
}

// Brand Type
Int m_brandcategory = 0;
Public int brandcategory
{
Get {return m_brandcategory ;}
Set {m_brandcategory = value ;}
}

// Display the number of entries
Int m_listnum = 0;
Public int listnum
{
Get {return m_listnum ;}
Set {m_listnum = value ;}
}

// Sort Fields
String m_orderfield = "ID ";
Public String orderfield
{
Get {return m_orderfield ;}
Set {m_orderfield = value ;}
}

// Where Condition
String m_wherestr = "";
Public String wherestr
{
Get {return m_wherestr ;}
Set {m_wherestr = value ;}
}

String m_text = "";

Public String text
{
Get {return m_text ;}
Set {m_text = value ;}
}

# Endregion

# Region obtain the HTML information of the product list

Public void getlistmsg ()
{
Stringbuilder STR = new stringbuilder ();
Try
{
Ucopration opt = new ucopration ();
Opt. productclass = productclass;
Opt. brandcategory = brandcategory;
Opt. listnum = listnum;
Opt. orderfield = orderfield;
Opt. wherestr = wherestr;

Str. append ("<ul> ");

Ilist list = idbuc. readlist (OPT );
For (INT I = 0; I <list. Count; I ++)
{
Uclist = (uclist) list [I];

String liststr = getcontent ();
If (type = 1)
Liststr = string. Format (liststr, "/product/productdetail. aspx? Id = "+ uclist. ID, uclist. IMG, uclist. productname, uclist. productname, uclist. oldprice, uclist. newprice );
Else if (type = 2)
Liststr = string. Format (liststr, "/product/productdetail. aspx? Id = "+ uclist. ID, uclist. IMG, uclist. productname, uclist. productname, uclist. newprice );
Else if (type = 3)
Liststr = string. Format (liststr, "/product/productdetail. aspx? Id = "+ uclist. ID, uclist. productname );
Str. append (liststr );
}

Str. append ("</ul> ");
}
Catch (exception ex)
{
Str. append (ex. Message );
}
TEXT = Str. tostring ();

}

// Content
Private string getcontent ()
{
If (type = 1)
Return @"
<Li>
<A href = '{0}' target = '_ blank'>

<Div class = 'item'>
{3}
<Label class = 'original-price'> {4} </label>
<Label class = 'special-price'> {5} </label>
</Div>
</A>
</LI> ";
Else if (type = 2)
Return @"
<Li>
<A href = '{0}' target = '_ blank'>

<Div> {3} </div>
<Span> <label class = 'special-price'> {4} </label> </span>
</A>
</LI> ";
Else
Return @"
<Li>
<A href = '{0}' target = '_ blank'> {1} </a>
</LI> ";
}

# Endregion

# Region output product list HTML Information

Protected override void render (htmltextwriter writer)
{
Writer. Write (this. Text. tostring ());
}

# Endregion

Source code call
<Uc1: productlisttag id = "tag1" type = "1" productclass = "-1" brandcategory = "0" listnum = "6" orderfield = "ID" wherestr = "" runat = "Server "> </uc1: productlisttag>

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.