Sage Development URL Replacement string

Source: Internet
Author: User

<summary>
The URL field value is replaced, no field is added
</summary>
<param name= "Strrepsource" > Source to be changed url</param>
<param name= "Strrepfield" > field, note the distinction between uppercase and lowercase. such as: ID or key37</param>
<param name= "Strnewvalue" > New value </param>
<returns> New url</returns> after replacement
public static string Urlreplace (String Strrepsource, String Strrepfield, String strnewvalue)
{
System.Text.StringBuilder Strbuilder = new System.Text.StringBuilder ();
BOOL Bswitch = false;

if (Strrepsource.contains ("&" + Strrepfield + "="))
{
Strrepfield = "&" + Strrepfield + "=";
Bswitch = true;
}
else if (Strrepsource.contains ("?" + Strrepfield + "="))
{
Strrepfield = "?" + Strrepfield + "=";
Bswitch = true;
}

if (bswitch)
{
string[] Strarray = Strrepsource.split (new string[] {Strrepfield}, 2, stringsplitoptions.removeemptyentries);
Strbuilder.append (Strarray[0]);
Strbuilder.append (Strrepfield);
Strbuilder.append (Strnewvalue);

if (strarray.length = = 2 && strarray[1]. Contains ("&"))
{
string[] Stray = strarray[1]. Split (new char[] {' & '}, 2, stringsplitoptions.removeemptyentries);
Strbuilder.append ("&" + stray[stray.length-1]);
}
}
Else
{
Strbuilder.append (Strrepsource);
Strbuilder.append (' & ');
Strbuilder.append (Strrepfield);
Strbuilder.append (' = ');
Strbuilder.append (Strnewvalue);
}

return strbuilder.tostring ();
}

<summary>
The URL field value is replaced. No this field is added
</summary>
<param name= "Strrepsource" > Source to be changed url</param>
<param name= "Strrepfield" > field, note the distinction between uppercase and lowercase. such as: ID or key37</param>
<param name= "iNewValue" > New value </param>
<returns> New url</returns> after replacement
public static string Urlreplace (String Strrepsource, string strrepfield, int inewvalue)
{
Return Urlreplace (Strrepsource, Strrepfield, inewvalue.tostring ());
}


<summary>
URL constructor
</summary>
<param name= "strURL" > Original url</param>
<param name= "Stridfield" > Entity ID field </param>
<param name= "Iidvalue" >id value </param>
<param name= "Strjvalue" > select values. Implement the corresponding selection card sag </param>
<returns> constructed URL with Key37 and Key58 values added </returns>
public static string Urlstructure (string strurl, String Stridfield, String iidvalue, String strjvalue)
{
strURL = Urlreplace (strURL, Stridfield, Iidvalue);
strURL = Urlreplace (strURL, "Key37", Iidvalue);
strURL = Urlreplace (strURL, "Key58", Iidvalue);
if (!string. IsNullOrEmpty (Strjvalue))
{
strURL = Urlreplace (strURL, "J", Strjvalue);
}
return strurl;
}

<summary>
Join the number of references
</summary>
public static string addparameters (string url, String k, String v)
{
if (!string. IsNullOrEmpty (k))
{
url = urlreplace (URL, K, v);
}
return URL;
}

<summary>
URL constructor
</summary>
<param name= "strURL" > Original url</param>
<param name= "Stridfield" > Entity ID field </param>
<param name= "Iidvalue" >id value </param>
<returns> post-constructed URL. Inclusion of Key37 and Key58 values </returns>
public static string Urlstructure (string strurl, string stridfield, int iidvalue)
{
strURL = Urlstructure (strURL, Stridfield, Iidvalue.tostring (), String. Empty);
return strurl;
}

<summary>
URL constructor
</summary>
<param name= "strURL" > Original url</param>
<param name= "Stridfield" > Entity ID field </param>
<param name= "Iidvalue" >id value </param>
<returns> post-constructed URL. Inclusion of Key37 and Key58 values </returns>
public static string Urlstructure (string strurl, String Stridfield, String iidvalue)
{
strURL = Urlstructure (strURL, Stridfield, Iidvalue, String. Empty);
return strurl;
}

Sage Development URL Replacement string

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.