Haha, this is wrong. I can't figure it out!

Source: Internet
Author: User
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?

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.