به يه مشکل برخورد کردم لطفا کمک ...

m1pfard

Member
راه درست اینه که شما آدرس رو به این صورت بدین:
http://localhost/khazon1/usersearch.aspx?myVal=test
در این صورت با کد زیر می تونید test رو بدست بیارین:
Requst.queryString('myVal')

اما اگه نخواین این طوری باشه باید اول محل ? رو در اون پیدا کنید (با دستورات InStr یا InStrRev).
سپس از اون محل تا آخر رشته رو بردارید (با دستور Mid)
 

khazon1

New Member
دوباره سلام
مهدی جان من با C# دارم برنامه نویسی میکنم و این فرمانی که شما گفتین رو نتونستم پیدا کنم .
اما تونستم با این فرمان :
Request.Url.Query.ToString();
کلمه ی test رو بدست بیارم با این تفاوت که یه علامت سئوال " ?test " ابتدای اون قرار گرفته ...
چطوری میتونم این علامت سئوال رو از این ببرم ؟؟؟
 

m1pfard

Member
راستش من #C بلد نیستم ولی اگه VB بود می تونستی از دستور Left یا Right استفاده کنید. این دستورات تعداد کاراکتر مشخصی را از چپ یا راست رشته بر می گردونن.
شما باید به اندازه 1- طول رشته تا از اونو بردارید.
 
یه لیست از متدهای کار با رشته براتون گذاشتم که ایشالا مشکلی نداشته باشید! ( توضیحات هم جلوشه - خیلی ساده و روون هم هستش )
با این کار کنید!
String.Substring

--------------------------------------------------------------------------------------------
کد:
Name  Description  
String.Insert 
 Inserts a specified string into the current instance 
 
String.PadLeft, String.PadRight 
 Adds characters to the left and right of the string, respectively 
 
String.Remove 
 Deletes a specified number of characters from the string, beginning at a specified character 
 
String.Replace 
 Replaces all occurrences of a specified character in the string with another specified character 
 
String.Split 
 Returns an array of substrings that are delimited by a specified character 
 
String.Substring 
 Returns a substring from the specified instance 
 
String.ToCharArray 
 Returns an array of the characters that make up the string 
 
String.ToLower, String.ToUpper 
 Returns the string converted to all lowercase or uppercase, respectively 
 
String.TrimEnd, String.TrimStart, String.Trim 
 Removes trailing, leading, or both characters from the string, respectively
 

جدیدترین ارسال ها

بالا