예제 #1
0
        public string ToJson()
        {
            // 这里忽略_staticObjects这个成员。

            if (_sessionItems == null || _sessionItems.Count == 0)
            {
                return(null);
            }

            Dictionary <string, object> dict = new Dictionary <string, object>(_sessionItems.Count);

            string key;

            NameObjectCollectionBase.KeysCollection keys = _sessionItems.Keys;
            for (int i = 0; i < keys.Count; i++)
            {
                key = keys[i];
                dict.Add(key, _sessionItems[key]);
            }

            SessionStateItem item = new SessionStateItem {
                Dict = dict, Timeout = this._timeout
            };

            return(JsonConvert.SerializeObject(item));
        }
예제 #2
0
        public static void ShowCookies(HttpCookieCollection cs, string Prefix)
        {
            ILog
                log = LogManager.GetLogger("System");

            log.Info("----------");

            NameObjectCollectionBase.KeysCollection
                keys = cs.Keys;

            string
                tmpString;

            HttpCookie
                c;

            foreach (string key in keys)
            {
                tmpString = Prefix + " Cookies[\"" + key + "\"]=\"" + cs[key].Value + "\"";

                log.Info(tmpString);

                c = cs[key];
            }

            log.Info("SessionID=\"" + HttpContext.Current.Session.SessionID + "\"");
        }
예제 #3
0
            public string ToJson()
            {
                // 这里忽略_staticObjects这个成员。

                if (_sessionItems == null || _sessionItems.Count == 0)
                {
                    return(null);
                }

                Dictionary <string, object> dict = new Dictionary <string, object>(_sessionItems.Count);

                string key;

                NameObjectCollectionBase.KeysCollection keys = _sessionItems.Keys;
                for (int i = 0; i < keys.Count; i++)
                {
                    key = keys[i];
                    dict.Add(key, _sessionItems[key]);
                }

                SessionStateItem item = new SessionStateItem {
                    Dict = dict, Timeout = this._timeout
                };

                return(HttpUtility.UrlEncode((new JavaScriptSerializer()).Serialize(item)));

                // 由于使用Dictionary<string, object>类型,造成复杂类型在序列化时就丢失了它们的类型信息,
                // 因此,在下面的反序列化时,就不能还原正原的类型。
                // 也正是因为此原因,CookieSessionStateStore只适合保存简单的基元类型数据。
            }
 internal static IEnumerable <string> AsEnumerable(this NameObjectCollectionBase.KeysCollection collection)
 {
     for (var i = 0; i < collection.Count; i++)
     {
         yield return(collection.Get(i));
     }
 }
예제 #5
0
        public void ProcessRequest(HttpContext context)
        {
            NameObjectCollectionBase.KeysCollection
                keys = context.Request.Form.Keys;

            string
                tmpString = string.Empty;

            foreach (string key in keys)
            {
                if (tmpString != string.Empty)
                {
                    tmpString += ", ";
                }
                tmpString += "Form[\"" + key + "\"]=\"" + context.Request.Form[key] + "\"";
            }

            context.Response.CacheControl = "no-cache";
            context.Response.Expires      = -1;
            context.Response.ContentType  = "application/json";

            JsonObject
                RootJsonObject = new JsonObject(new Dictionary <string, object> {
                { "success", false }, { "errors", new JsonObject(new Dictionary <string, object> {
                        { "title", "Sounds like a Chick Flick" }
                    }) }, { "errormsg", "That movie title sounds like a chick flick." }
            });

            JsonTextWriter
                tmpJsonTextWriter = new JsonTextWriter(context.Response.Output);

            RootJsonObject.Export(tmpJsonTextWriter);
            tmpJsonTextWriter.Flush();
            tmpJsonTextWriter.Close();
        }
예제 #6
0
        private void DataStaff_SortCommand(object source, DataGridSortCommandEventArgs e)
        {
            string
                tmpString = "<h1 align=\"center\">Session</h1><hr align=\"center\"><br>";

            tmpString += "Session.CodePage=" + Session.CodePage + "<br>";
            tmpString += "Response.ContentEncoding.CodePage=" + Response.ContentEncoding.CodePage + "<br>";
            tmpString += "Session.Count=" + Session.Count + "<br>";
            tmpString += "Session.IsCookieless=" + Session.IsCookieless + "<br>";
            tmpString += "Session.IsNewSession=" + Session.IsNewSession + "<br>";
            tmpString += "Session.IsReadOnly=" + Session.IsReadOnly + "<br>";
            tmpString += "Session.IsSynchronized=" + Session.IsSynchronized + "<br>";

            NameObjectCollectionBase.KeysCollection
                keys = Session.Keys;

            foreach (string key in keys)
            {
                tmpString += "Session.Keys: " + key + "<br>";
            }

            tmpString       += "Session.LCID=" + Session.LCID + " (0x" + Session.LCID.ToString("x") + ")<br>";
            tmpString       += "Session.Mode=" + Session.Mode + "<br>";
            tmpString       += "Session.SessionID=" + Session.SessionID + "<br>";
            tmpString       += "Session.StaticObjects.Count=" + Session.StaticObjects.Count + "<br>";
            tmpString       += "Session.Timeout=" + Session.Timeout + "<br>";
            SessionInfo.Text = tmpString;

            view                 = (DataView)Session["view"];
            view.Sort            = e.SortExpression;
            DataStaff.DataSource = view;
            DataStaff.DataBind();
        }
예제 #7
0
 public void CopyTo(Array array, int index)
 {
     NameObjectCollectionBase.KeysCollection all = Keys;
     for (int i = 0; i < all.Count; i++)
     {
         array.SetValue(all.Get(i), i + index);
     }
 }
 public static IEnumerable <string> AsEnumerable(
     this NameObjectCollectionBase.KeysCollection keysCollection
     )
 {
     for (var i = 0; i < keysCollection.Count; i++)
     {
         yield return(keysCollection[i]);
     }
 }
예제 #9
0
        /// <summary>
        /// 初始化
        /// </summary>
        private void Init()
        {
            NameObjectCollectionBase.KeysCollection FormElements = _page.Request.Form.Keys;
            int count = FormElements.Count;

            for (int i = 0; i < count; i++)
            {
                this.Add(new HtmlElement(_AjaxEngine, FormElements[i]));
            }
        }
예제 #10
0
 public void CopyTo(Array array, int index)
 {
     if (sessionItems == null)
     {
         return;
     }
     NameObjectCollectionBase.KeysCollection all = sessionItems.Keys;
     for (int i = 0; i < all.Count; i++)
     {
         array.SetValue(all.Get(i), i + index);
     }
 }
예제 #11
0
        public static bool Contains(this NameObjectCollectionBase.KeysCollection keys, string key)
        {
            for (int i = 0; i < keys.Count; ++i)
            {
                var item = keys.Get(i);
                if (item == key)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #12
0
        protected bool SessionContainsKey(string key)
        {
            NameObjectCollectionBase.KeysCollection keys_collection = Session.Keys;

            foreach (object keyi in keys_collection)
            {
                if (keyi.ToString() == key)
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #13
0
        private string getSessionKeys(string heading, NameObjectCollectionBase.KeysCollection keyObj)
        {
            string o = "";

            o += "<table border='0' cellspacing='0' style='font-face:arial;'>";
            o += "<tr><td colspan='2'>" + heading + "</td></tr>";
            foreach (string key in keyObj)
            {
                o += "<tr><td style='font-face:arial;'>" + key + "</td><td style='font-face:arial;'>" + Session[key] + "</td></tr>";
            }
            o += "</table><br/><br/>";
            return(o);
        }
예제 #14
0
        public void Keys_GetEnumerator_Invalid(int count)
        {
            MyNameObjectCollection nameObjectCollection = Helpers.CreateNameObjectCollection(count);

            NameObjectCollectionBase.KeysCollection keys = nameObjectCollection.Keys;
            IEnumerator enumerator = keys.GetEnumerator();

            // Has not started enumerating
            Assert.Throws <InvalidOperationException>(() => enumerator.Current);

            // Has finished enumerating
            while (enumerator.MoveNext())
            {
                ;
            }
            Assert.Throws <InvalidOperationException>(() => enumerator.Current);

            // Has reset enumerating
            enumerator.Reset();
            Assert.Throws <InvalidOperationException>(() => enumerator.Current);

            // Modify collection
            enumerator.MoveNext();
            nameObjectCollection.Add("new-name", new Foo("new-value"));
            Assert.Throws <InvalidOperationException>(() => enumerator.MoveNext());
            Assert.Throws <InvalidOperationException>(() => enumerator.Reset());
            if (count > 0)
            {
                Assert.NotNull(enumerator.Current);
            }

            // Modified read only collection still throws
            nameObjectCollection.IsReadOnly = true;
            Assert.Throws <InvalidOperationException>(() => enumerator.MoveNext());
            Assert.Throws <InvalidOperationException>(() => enumerator.Reset());

            // Clear collection
            nameObjectCollection.IsReadOnly = false;
            enumerator = keys.GetEnumerator();
            enumerator.MoveNext();
            nameObjectCollection.Clear();
            Assert.Throws <InvalidOperationException>(() => enumerator.Current);
            Assert.Throws <InvalidOperationException>(() => enumerator.MoveNext());
            Assert.Throws <InvalidOperationException>(() => enumerator.Reset());
        }
예제 #15
0
        public void Keys_GetEnumerator(int count)
        {
            MyNameObjectCollection nameObjectCollection = Helpers.CreateNameObjectCollection(count);

            NameObjectCollectionBase.KeysCollection keys = nameObjectCollection.Keys;
            Assert.NotSame(keys.GetEnumerator(), keys.GetEnumerator());

            IEnumerator enumerator = keys.GetEnumerator();

            for (int i = 0; i < 2; i++)
            {
                int counter = 0;
                while (enumerator.MoveNext())
                {
                    Assert.Equal(keys[counter], enumerator.Current);
                    counter++;
                }
                Assert.Equal(count, keys.Count);
                enumerator.Reset();
            }
        }
예제 #16
0
        public void Keys_CopyTo_Invalid(int count)
        {
            MyNameObjectCollection nameObjectCollection = Helpers.CreateNameObjectCollection(count);

            NameObjectCollectionBase.KeysCollection keys = nameObjectCollection.Keys;
            ICollection keysCollection = keys;

            AssertExtensions.Throws <ArgumentNullException>("array", () => keysCollection.CopyTo(null, 0));
            AssertExtensions.Throws <ArgumentException>("array", null, () => keysCollection.CopyTo(new string[count, count], 0));

            if (count > 0)
            {
                AssertExtensions.Throws <ArgumentException>(null, () => keysCollection.CopyTo(new string[0], 0));
                AssertExtensions.Throws <ArgumentException>(null, () => keysCollection.CopyTo(new string[count - 1], 0));

                Assert.Throws <InvalidCastException>(() => keysCollection.CopyTo(new Foo[count], 0));
            }

            AssertExtensions.Throws <ArgumentOutOfRangeException>("index", () => keysCollection.CopyTo(new string[count], -1));
            AssertExtensions.Throws <ArgumentException>(null, () => keysCollection.CopyTo(new string[count], 1));
            AssertExtensions.Throws <ArgumentException>(null, () => keysCollection.CopyTo(new string[count], count + 1));
        }
        public string ToJson()
        {
            // 这里忽略_staticObjects这个成员。

            if (_sessionItems == null || _sessionItems.Count == 0)
            {
                return(null);
            }

            Dictionary <string, SaveValue> dict = new Dictionary <string, SaveValue>(_sessionItems.Count);

            NameObjectCollectionBase.KeysCollection keys = _sessionItems.Keys;
            string key;
            object objectValue = string.Empty;
            Type   type        = null;

            for (int i = 0; i < keys.Count; i++)
            {
                key         = keys[i];
                objectValue = _sessionItems[key];
                if (objectValue != null)
                {
                    type = objectValue.GetType();
                }
                else
                {
                    type = typeof(object);
                }
                dict.Add(key, new SaveValue {
                    Value = objectValue, Type = type
                });
            }

            SessionStateItem item = new SessionStateItem {
                Dict = dict, Timeout = this._timeout
            };

            return(JsonConvert.SerializeObject(item));
        }
예제 #18
0
        protected void ButtonClearList_Click(object sender, EventArgs e)
        {
            Session["Student_Id"] = null;
            BookIssues            = new List <book_issue>();
            NameObjectCollectionBase.KeysCollection Keys = Session.Keys;
            for (int i = 0; i < Keys.Count; i++)
            {
                string key = Keys[i];
                if (key.Contains("BookIssues_"))
                {
                    Session[key] = null;
                    Book         = null;
                }

                if (key.Contains("CurrentBook_"))
                {
                    Session[key] = null;
                    BookRecord   = null;
                }

                if (key.Contains("CurrentBookRecord_"))
                {
                    Session[key] = null;
                }
            }

            /*Session["BookIssues_"+CurrentStudent.id] = null;
             * Book = null;
             * Session["CurrentBook_"+CurrentStudent.id]= null;
             * BookRecord = null;
             * Session["CurrentBookRecord_"+CurrentStudent.id] = null;*/
            TextBoxStudentID.Text = "";
            PanelBookIssues.Controls.Clear();
            PanelBookList.Controls.Clear();
            InitPage();
            ShowCurrentBook("");
            LabelRecordList.Text = "";
        }
예제 #19
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (IsPostBack)
            {
                string
                    tmpString = string.Empty;

                NameObjectCollectionBase.KeysCollection
                    inpt = Request.Form.Keys;

                for (int i = 0; i < inpt.Count; ++i)
                {
                    if (tmpString != string.Empty)
                    {
                        tmpString += "<br>";
                    }

                    tmpString += inpt[i];
                }

                Label1.Text = tmpString;
            }
        }
예제 #20
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            NameObjectCollectionBase.KeysCollection
                                                   inpt = Request.Form.Keys;

            string
                tmpString = string.Empty;

            string[]
            tmpStrings;

            for (int i = 0; i < inpt.Count; ++i)
            {
                tmpStrings = Request.Form.GetValues(inpt[i]);

                if (tmpString != string.Empty)
                {
                    tmpString += " ";
                }

                tmpString += inpt[i];

                if (tmpStrings != null)
                {
                    tmpString += "=";
                    for (int j = 0; j < tmpStrings.Length; ++j)
                    {
                        tmpString += "\"" + tmpStrings[j] + "\"";
                    }
                }
            }

            Session[HtmlAspxSearchResultForm.HtmlAspxSearchResultFormDataSessionSignature] = tmpString;

            Response.Redirect(Request.UrlReferrer.AbsolutePath, true);
        }
예제 #21
0
        public void ProcessRequest(HttpContext context)
        {
            string
                tmpString;

            context.Request.InputStream.Seek(0, SeekOrigin.Begin);
            var streamReader = new StreamReader(context.Request.InputStream, Encoding.UTF8);

            tmpString = streamReader.ReadToEnd().Trim();

            context.Response.CacheControl = "no-cache";
            context.Response.Expires      = -1;

            NameObjectCollectionBase.KeysCollection
                keys = context.Request.Form.Keys;

            tmpString = string.Empty;

            foreach (string key in keys)
            {
                if (tmpString != string.Empty)
                {
                    tmpString += ", ";
                }
                tmpString += "Form[\"" + key + "\"]=\"" + context.Request.Form[key] + "\"";
            }

            string
                Act,
                Id       = context.Request.Form["id"],
                FileName = string.Empty;

            switch (Act = context.Request.Form["act"])
            {
            case "getPicture":
            {
                FileName = "./img/27265.gif";

                //context.Response.ContentType = "text/html";
                context.Response.ContentType = "application/json";

                JsonObject
                    RootJsonObject = new JsonObject(new Dictionary <string, object> {
                        { "success", true }, { "data", new Dictionary <string, object> {
                                                   { "contactId", "contact id" }, { "file", FileName }
                                               } }
                    });

                JsonTextWriter
                    tmpJsonTextWriter = new JsonTextWriter(context.Response.Output);

                RootJsonObject.Export(tmpJsonTextWriter);
                tmpJsonTextWriter.Flush();
                tmpJsonTextWriter.Close();

                break;
            }

            case "setPicture":
            {
                if (context.Request.Files.Count != 0)
                {
                    string
                        DestDir;

                    if (!Directory.Exists(DestDir = context.Server.MapPath(null) + Path.DirectorySeparatorChar + "download"))
                    {
                        Directory.CreateDirectory(DestDir);
                    }

                    if (File.Exists(FileName = DestDir + Path.DirectorySeparatorChar + Path.GetFileName(context.Request.Files[0].FileName)))
                    {
                        File.Delete(FileName);
                    }

                    byte[]
                    Img = new byte[context.Request.Files[0].ContentLength];

                    context.Request.Files[0].InputStream.Read(Img, 0, Img.Length);

                    FileStream
                        fs = new FileStream(FileName, FileMode.Create);

                    fs.Write(Img, 0, Img.Length);
                    fs.Close();

                    FileName = "./download/" + Path.GetFileName(context.Request.Files[0].FileName);

                    context.Response.ContentType = "text/html";
                    context.Response.Write("<html><body><textarea>{ \"success\": \"true\", \"data\": { \"contactId\": \"contact id\", \"file\": \"" + FileName + "\" } }</textarea></body></html>");
                    context.Response.Flush();
                }

                break;
            }

            default:
            {
                throw(new Exception("Unknown act=\"" + Act + "\""));
            }
            }
        }
예제 #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                TextBoxReadOnly.Text         = "TextBoxReadOnly.Text";
                TextBoxDisabled.Text         = "TextBoxDisabled.Text";
                TextBoxReadOnlyDisabled.Text = "TextBoxReadOnlyDisabled.Text";
                TextBoxOrdinary.Text         = "TextBoxOrdinary.Text";
            }
            else
            {
                string
                    vPath = "~/controls/images/wall.gif",
                    tmpString;

                tmpString = Context.Request.CurrentExecutionFilePath;
                tmpString = System.Web.VirtualPathUtility.GetDirectory(vPath);
                tmpString = System.Web.VirtualPathUtility.ToAbsolute(vPath);

                string[]
                array1 = Request.Form.AllKeys;

                LabelAllKeys.Text = string.Empty;
                LabelValue.Text   = string.Empty;
                for (int i = 0; i < array1.Length; ++i)
                {
                    if (LabelAllKeys.Text != string.Empty)
                    {
                        LabelAllKeys.Text += "<br>";
                    }
                    LabelAllKeys.Text += "Key [" + i + "]=" + array1[i];

                    string[]
                    array2;

                    tmpString = string.Empty;
                    if ((array2 = Request.Form.GetValues(array1[i])) != null)
                    {
                        for (int j = 0; j < array2.Length; ++j)
                        {
                            if (tmpString != string.Empty)
                            {
                                tmpString += "<br>";
                            }
                            tmpString += "\"" + array2[j] + "\"";
                        }
                    }

                    if (LabelValue.Text != string.Empty)
                    {
                        LabelValue.Text += "<br>";
                    }
                    LabelValue.Text += "\"" + array1[i] + "\"=" + tmpString;
                }

                NameObjectCollectionBase.KeysCollection
                    input = Request.Form.Keys;

                LabelKeys.Text = string.Empty;
                for (int i = 0; i < input.Count; ++i)
                {
                    if (LabelKeys.Text != string.Empty)
                    {
                        LabelKeys.Text += "<br>";
                    }
                    LabelKeys.Text += input[i];
                }

                tmpString  = "TextBoxReadOnly.Text=\"" + TextBoxReadOnly.Text + "\"<br>";
                tmpString += " TextBoxDisabled.Text=\"" + TextBoxDisabled.Text + "\"<br>";
                tmpString += " TextBoxReadOnlyDisabled.Text=\"" + TextBoxReadOnlyDisabled.Text + "\"<br>";
                tmpString += " TextBoxOrdinary.Text=\"" + TextBoxOrdinary.Text + "\"";

                LabelText.Text = tmpString;
            }
        }
예제 #23
0
        public void ProcessRequest(HttpContext context)
        {
            System.Threading.Thread.Sleep(5000);

            string
                tmpString;

            context.Request.InputStream.Seek(0, SeekOrigin.Begin);
            var streamReader = new StreamReader(context.Request.InputStream, Encoding.UTF8);

            tmpString = streamReader.ReadToEnd().Trim();

            context.Response.CacheControl = "no-cache";
            context.Response.Expires      = -1;

            NameObjectCollectionBase.KeysCollection
                keys = context.Request.Form.Keys;

            tmpString = string.Empty;

            foreach (string key in keys)
            {
                if (tmpString != string.Empty)
                {
                    tmpString += ", ";
                }
                tmpString += "Form[\"" + key + "\"]=\"" + context.Request.Form[key] + "\"";
            }

            string
                id       = context.Request.Form["id"],
                fileName = string.Empty;

            if (context.Request.Files.Count != 0)
            {
                string
                    destDir;

                if (!Directory.Exists(destDir = context.Server.MapPath(null) + Path.DirectorySeparatorChar + "download"))
                {
                    Directory.CreateDirectory(destDir);
                }

                if (File.Exists(fileName = destDir + Path.DirectorySeparatorChar + Path.GetFileName(context.Request.Files[0].FileName)))
                {
                    File.Delete(fileName);
                }

                byte[]
                file = new byte[context.Request.Files[0].ContentLength];

                context.Request.Files[0].InputStream.Read(file, 0, file.Length);

                FileStream
                    fs = new FileStream(fileName, FileMode.Create);

                fs.Write(file, 0, file.Length);
                fs.Close();

                fileName = "./download/" + Path.GetFileName(context.Request.Files[0].FileName);

                context.Response.ContentType = "text/html";
                context.Response.Write("<html><body><textarea>{ \"success\": \"true\", \"data\": { \"contactId\": \"contact id\", \"file\": \"" + fileName + "\" } }</textarea></body></html>");
                context.Response.Flush();
            }
        }
예제 #24
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            ListItem
                tmpListItem;

            if (!IsPostBack)
            {
                tmpListItem = new ListItem("Text #1", "1");
                DDLSwitch.Items.Add(tmpListItem);
                tmpListItem = new ListItem("Text #2", "2");
                DDLSwitch.Items.Add(tmpListItem);
                tmpListItem = new ListItem("Text #3", "3");
                DDLSwitch.Items.Add(tmpListItem);

                tmpListItem = new ListItem();
                DDLSwitch.Items.Insert(0, tmpListItem);
            }
            else
            {
                if ((tmpListItem = DDLSwitch.Items.FindByValue(string.Empty)) != null)
                {
                    DDLSwitch.Items.Remove(tmpListItem);
                }
            }

            if (!IsPostBack)
            {
                VehicleTypes.Text  = MakeCheckBox(null, false);
                VehicleTypesS.Text = MakeCheckBox(null, true);
            }
            else
            {
                string[]
                array1,
                array2;

                string
                    val;

                int
                    i,
                    ii;

                ParagraphRequest.Text = "Request.Params.Count: \"" + Request.Params.Count + "\"<br>";
                array1 = Request.Params.AllKeys;
                for (i = 0; i < array1.Length; ++i)
                {
                    ParagraphRequest.Text += "Key [" + Convert.ToString(i) + "]=" + Server.HtmlEncode(array1[i]) + "<br>";
                    array2 = Request.Params.GetValues(array1[i]);
                    for (ii = 0; ii < array2.Length; ++ii)
                    {
                        ParagraphRequest.Text += "Value [" + Convert.ToString(ii) + "]=" + Server.HtmlEncode(array2[ii]) + "<br>";
                    }
                }
                ParagraphRequest.Text += "<br>";

                array2 = Request.Params.GetValues("SwitchDIV");
                if (array2 != null)
                {
                    val = Server.HtmlEncode(array2[0]);
                    switch (val.ToLower())
                    {
                    case "on":
                    {
                        val = "block";

                        break;
                    }

                    case "off":
                    {
                        val = "none";

                        break;
                    }
                    }
                    divT.Style["display"] = val;
                }

                ArrayList
                    Checked = new ArrayList();

                for (char c = 'A'; c < 'F'; ++c)
                {
                    array2 = Request.Params.GetValues("CheckBox" + c);
                    if (array2 == null)
                    {
                        continue;
                    }

                    val = Server.HtmlEncode(array2[0]);
                    if (val.ToLower() == "on")
                    {
                        Checked.Add(c);
                    }
                }
                VehicleTypes.Text = MakeCheckBox(Checked, false);

                array2 = Request.Params.GetValues("DDLSwitch");
                if (array2 != null)
                {
                    val = Server.HtmlEncode(array2[0]);
                    ParagraphRequest.Text += "DDLSwitch.value=\"" + val + "\"<br>";
                }
                ParagraphRequest.Text += "<br>";

                HtmlInputRadioButton
                    tmpHtmlInputRadioButton;

                HtmlInputText
                    tmpHtmlInputText;

                HtmlInputCheckBox
                    tmpHtmlInputCheckBox;

                string
                    r = string.Empty;

                if ((tmpHtmlInputRadioButton = FindControl(SignatureRadio + "1") as HtmlInputRadioButton) != null)
                {
                    if (r != string.Empty)
                    {
                        r += Environment.NewLine;
                    }
                    r += SignatureRadio + "1.Checked=" + tmpHtmlInputRadioButton.Checked.ToString();
                }
                if ((tmpHtmlInputRadioButton = FindControl(SignatureRadio + "2") as HtmlInputRadioButton) != null)
                {
                    if (r != string.Empty)
                    {
                        r += Environment.NewLine;
                    }
                    r += SignatureRadio + "2.Checked=" + tmpHtmlInputRadioButton.Checked.ToString();
                }
                if ((tmpHtmlInputText = FindControl(SignatureText) as HtmlInputText) != null)
                {
                    if (r != string.Empty)
                    {
                        r += Environment.NewLine;
                    }
                    r += SignatureText + ".Value=" + tmpHtmlInputText.Value;
                }
                if ((tmpHtmlInputCheckBox = FindControl(SignatureCheckBox) as HtmlInputCheckBox) != null)
                {
                    if (r != string.Empty)
                    {
                        r += Environment.NewLine;
                    }
                    r += SignatureCheckBox + ".Checked=" + tmpHtmlInputCheckBox.Checked.ToString();
                }

                if (ViewState["SwitchDIV"] != null)
                {
                    if (r != string.Empty)
                    {
                        r += Environment.NewLine;
                    }
                    r += ViewState["SwitchDIV"];
                }
                if (ViewState["SwitchDIVOn"] != null)
                {
                    if (r != string.Empty)
                    {
                        r += Environment.NewLine;
                    }
                    r += ViewState["SwitchDIV"];
                }
                if (ViewState["SwitchDIVOff"] != null)
                {
                    if (r != string.Empty)
                    {
                        r += Environment.NewLine;
                    }
                    r += ViewState["SwitchDIV"];
                }

                ParagraphRequest.Text += "Request.Form.Count: \"" + Request.Form.Count + "\"<br>";
                array1 = Request.Form.AllKeys;
                for (i = 0; i < array1.Length; ++i)
                {
                    ParagraphRequest.Text += "Key [" + Convert.ToString(i) + "]=" + Server.HtmlEncode(array1[i]) + "<br>";
                    array2 = Request.Form.GetValues(array1[i]);
                    for (ii = 0; ii < array2.Length; ++ii)
                    {
                        ParagraphRequest.Text += "Value [" + Convert.ToString(ii) + "]=" + Server.HtmlEncode(array2[ii]) + "<br>";
                    }
                }
                ParagraphRequest.Text += "<br>";

                NameObjectCollectionBase.KeysCollection
                    inpt = Request.Form.Keys;

                for (i = 0; i < inpt.Count; ++i)
                {
                    ParagraphRequest.Text += inpt[i] + "<br>";
                }
                ParagraphRequest.Text += "<br>";
            }

            CheckBox
                tmpCheckBox = new CheckBox();

            tmpCheckBox.ID              = "CheckBoxDynamicServerPageLoad";
            tmpCheckBox.CheckedChanged += new EventHandler(CheckBox_CheckedChanged);
            PlaceHolder4CheckBoxDynamicServer.Controls.Add(tmpCheckBox);
        }
예제 #25
0
        public void ProcessRequest(HttpContext context)
        {
            NameObjectCollectionBase.KeysCollection
                keys = context.Request.Form.Keys;

            string
                tmpString = string.Empty;

            foreach (string key in keys)
            {
                if (tmpString != string.Empty)
                {
                    tmpString += ", ";
                }
                tmpString += "Form[\"" + key + "\"]=\"" + context.Request.Form[key] + "\"";
            }

            context.Response.CacheControl = "no-cache";
            context.Response.Expires      = -1;
            context.Response.ContentType  = "application/json";

            /*
             * JsonObject
             *      RootJsonObject = new JsonObject(new Dictionary<string, object> {
             *              { "success", false },
             *              { "errorMessage", "errorMessage" }
             *      });
             */

            JsonObject
                RootJsonObject = new JsonObject(new Dictionary <string, object> {
                { "success", true },
                { "data", new JsonObject(new Dictionary <string, object> {
                        { "HiddenField1", 123456 },
                        { "NumberField", "123456" },
                        { "TextField", "dleiFtxeT" },
                        { "DateField", "17.06.2010" },
                        { "TimeField", "13:00" },
                        { "DateTimeField", new DateTime(2010, 06, 17, 13, 0, 13).ToString("o") },
                        { "Radio", "Radio2" },
                        { "CheckBox", "1" },
                        { "TextArea", "TextArea" },
                        { "HtmlEditor", "HtmlEditor" },
                        //{ "ComboBox1", "778" },
                        //{ "ComboBox1", 778 },
                        { "ComboBox1HN", "FOTO  ГРAЧИ УЛЕТЕЛИ" },                 // 778
                        //{ "ComboBox2", "800" },
                        { "ComboBox2HN", "FOTO  ГРАЧИ БЕЗНАЛИЧНЫЕ" },             // 800
                        { "ComboBox3HN", "9" },
                        //{ "ComboBox4HN", "11" }
                        { "ComboBox4", 11 }
                    }) }
            });

            JsonTextWriter
                tmpJsonTextWriter = new JsonTextWriter(context.Response.Output);

            RootJsonObject.Export(tmpJsonTextWriter);
            tmpJsonTextWriter.Flush();
            tmpJsonTextWriter.Close();
        }
예제 #26
0
 public static bool Any(this NameObjectCollectionBase.KeysCollection k, Func <string, bool> predicate)
 {
     return(k.Cast <string>().Any(predicate));
 }