Asp.net intercepts string code

Source: Internet
Author: User

1.CodePut it in sqlhelper. Copy code The Code is as follows: # region intercepts a string
/// <Summary>
/// Capture a string
/// </Summary>
/// <Param name = "str_value"> </param>
/// <Param name = "str_len"> </param>
/// <Returns> </returns>
Public static string leftx (string str_value, int str_len)
{
Int p_num = 0;
Int I;
String new_str_value = "";
If (str_value = "")
{
New_str_value = "";
}
Else
{
Int len_num = str_value.length;
For (I = 0; I <= len_num-1; I ++)
{
If (I> len_num) break;
Char c = convert. tochar (str_value.substring (I, 1 ));
If (INT) C> 255) | (INT) C <0 ))
P_num = p_num + 2;
Else
P_num = p_num + 1;
If (p_num> = str_len)
{
New_str_value = str_value.substring (0, I + 1 );
Break;
}
Else
{
New_str_value = str_value;
}
}
}
Return new_str_value;
}
# Endregion

2. Foreground call: Copy codeThe Code is as follows: <% # userinfo. Dal. sqlhelper. leftx (databinder. eval (container. dataitem, "title"). tostring (), 20) %>

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.