How to reference the methods in the component DLL written by yourself in Dreamweaver

Source: Internet
Author: User

Many times I wantDreamweaverCan you support methods in the class you write? Because it is really strong in fast development, but many detailed functions cannot be implemented. For example, I want to process the specified string, frequently used is the display of the news topic list on the homepage of the website. The length of each line is greater"..."Display. In general sense, you can add this method to the desired page. However, if there are many such pages, paste this method once for each page, if there is any modification, it is even more troublesome. This is also contrary to the object-oriented principle, so I thought of encapsulating the methods commonly used in website development into a class and then introducing this namespace into the corresponding page. Below I will give someCodeExample

FirstVs2003CreateClassThe project is as follows:

Using system;

Using system. Data;

Using system. Data. sqlclient;

Using system. configuration;

 

Namespace aspnetx

{

/// <Summary>

/// Summary description for aspnetx.

///This class mainly defines some common business logic for website development

///This can simplify website project development and save a lot of coding time.

/// </Summary>

Public class aspnetx

{

......

......

......

/// <Summary>

///Generated according to the specified lengthArticleQuestion

///Move the mouse to display the full name.

/// </Summary>

/// <Param name = "str">String to be processed</Param>

/// <Param name = "length">Article Length</Param>

/// <Returns> </returns>

Public static string titlestring (string STR, int length)

{

Int I = 0, j = 0;

 

STR = Str. Trim ();

 

String str_s = STR;//The passed string, used when the full name is displayed

 

Foreach (char CHR in Str)

{

If (INT) CHR> 127)

{

I + = 2;

}

Else

{

I ++;

}

If (I> length)

{

STR = Str. substring (0, j) + "......";

Break;

}

J ++;

}

//Join thisHtmlThe Code moves the mouse to display the full name

STR = "<font Title = '" + str_s + "'>" + STR + "</font> ";

 

Return STR;

}

}

}

 

CompileBinDirectoryAspnetx. dllDifferent projects may generate differentDLL

Copy to the website directoryBinFolder, then open the page to be introduced, and add

<% @ Import namespace = "aspnetx" %>

You can modify the reference method based on your compilation. For example:

<% # Aspnetx. titlestring (dataset1.fieldvalue ("newstitle", container), 40) %>

 

I think this method is good for small projects. You can add some other methods to it.

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.