| |||||
HttpCookie.HasKeys PropertySystem.Web Namespace HttpCookie Class Gets a value indicating whether a cookie has subkeys. [ VB ] Public ReadOnly Property HasKeys As Boolean [ C# ] public bool HasKeys {get;} [ C++ ] public: __property bool get_HasKeys ( ); [ JScript ] public function get HasKeys ( ) : Boolean; Property Valuetrue if the cookies has subkeys, otherwise, false. The default value is false. ExampleThe following example examines each member of a cookie collection for multiple values and If multiple values are present ( HasKeys = true ) , copies the value names into one string array and the corresponding values into another string array. For an example of how to create multiple values for a cookie, see Values. [ VB ] Dim myCookieCollection As HttpCookieCollection Dim myCookie As HttpCookie Dim MyValueNames ( ) As String Dim MyValues ( ) As String Dim loop1 As Integer myCookieCollection = Request.Cookies For loop1 = 0 To myCookieCollection.Count - 1 myCookie = myCookieCollection ( loop1 ) If myCookie.HasKeys Then Dim myCookieValues As NameValueCollection = new NameValueCollection ( myCookie.Values ) MyValueNames = myCookieValues.AllKeys MyValues = myCookieValues.AllKeys End If Next loop1 [ C# ] HttpCookieCollection myCookieCollection = Request.Cookies; for ( int loop1 = 0; loop1 < myCookieCollection.Count; loop1++ ) { HttpCookie myCookie = myCookieCollection [ loop1 ]; if ( myCookie.HasKeys ) { NameValueCollection myCookieValues = new NameValueCollection ( myCookie.Values ); String [ ] MyValueNames = myCookieValues.AllKeys; String [ ] MyValues = myCookieValues.AllKeys; } } [ JScript ] var myCookieCollection : HttpCookieCollection var myCookie : HttpCookie var myValueNames : String [ ] var myValues : String [ ] myCookieCollection = Request.Cookies for ( var loop1 = 0; loop1 < myCookieCollection.Count; loop1++ ) { myCookie = myCookieCollection [ loop1 ] if ( myCookie.HasKeys ) { var myCookieValues : NameValueCollection = new NameValueCollection ( myCookie.Values ) myValueNames = myCookieValues.AllKeys myValues = myCookieValues.AllKeys } } See Also |
| ||||
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme