This is written using notepad (Notepad ). Code
Using System;
Using System. IO;
Public Class Test
{
Public Static Void Main ( String [] Arg)
{
If (Arg. Length < 1 )
{
Return;
}
String URL = Arg [ 0 ];
Int Begin = URL. lastindexof ( " / " ) + 1 ;
Console. writeline (BEGIN );
Int End = URL. lastindexof ( " ? " ) - URL. lastindexof ( " / " ) - 1 ;
Console. writeline (end );
Console. writeline (URL. substring (begin, end ));
}
}
It is used to intercept character substrings. The parameters are in Arg and run normally.
The following statements are written in Asp.net: Private Void Page_load ( Object Sender, system. eventargs E)
{
// Place user code here to initialize the page
String URL = Request. url. tostring (). Trim ();
If (URL. Length > 0 )
{
Int Begin = URL. lastindexof ( " / " ) + 1 ;
String Compurl = " Bookdetail. aspx " ;
If (URL. substring (begin, 15 ) = Compurl)
{< br> This . datalist1.repeatdirection = repeatdirection. horizontal;
This . datalist1.repeatcolumns = 20 ;< BR >}
}
Datalist1.datasource = New Guanli. component_tushu (). gettypelist ();;
Datalist1.databind ();
}
This is to dynamically change the appearance of our datalist. When the requested page is different, its display is also different.
However, the following error is prompted during running: Exception details: system. argumentoutofrangeexception: The index and length must reference the position in the string. Parameter Name: Length
Source error:
Line 28 : // Int end = URL. lastindexof ("? ")-URL. lastindexof ("/")-1;
Line 29 : String Compurl = " Bookdetail. aspx " ;
Line 30 : If (URL. substring (begin, 15 ) = Compurl)
Line 31 : {
Line32:This. Datalist1.repeatdirection=Repeatdirection. horizontal;
Source File: F: \ myweb \ myprg \ typelist. ascx. CS row:30
It's hard to figure out. Can you give me some suggestions?