예제 #1
0
        public void IPostBackDataHandler_LoadPostData_NullCollection()
        {
            TestHtmlInputRadioButton rb   = new TestHtmlInputRadioButton();
            IPostBackDataHandler     pbdh = (rb as IPostBackDataHandler);

            pbdh.LoadPostData("id1", null);
        }
예제 #2
0
        public void LoadAndRaise1()
        {
            RadioButtonList rbl = new RadioButtonList();

            rbl.Items.Add(new ListItem("Uno", "1"));
            rbl.Items.Add(new ListItem("Dos", "2"));
            rbl.Items.Add(new ListItem("Tres", "3"));
            rbl.SelectedIndex = 2;
            NameValueCollection nvc = new NameValueCollection();

            nvc ["XXX"] = "3";

            IPostBackDataHandler handler = (IPostBackDataHandler)rbl;

#if NET_2_0
            Assert.IsFalse(handler.LoadPostData("XXX", nvc), "#01");
#else
            Assert.IsTrue(handler.LoadPostData("XXX", nvc), "#01");
#endif
            rbl.SelectedIndexChanged += new EventHandler(OnSelected);
            event_called              = false;
            handler.RaisePostDataChangedEvent();
#if NET_2_0
            Assert.IsTrue(event_called, "#02");
#else
            // Not called. Value is the same as the selected previously
            Assert.IsFalse(event_called, "#02");
#endif
            Assert.AreEqual("3", rbl.SelectedValue, "#03");
        }
예제 #3
0
        public void IPostBackDataHandler_LoadPostData_NullCollection()
        {
            TestHtmlInputText    it   = new TestHtmlInputText("password");
            IPostBackDataHandler pbdh = (it as IPostBackDataHandler);

            pbdh.LoadPostData("id1", null);
        }
예제 #4
0
        public void IPostBackDataHandler_LoadPostData_NullCollection()
        {
            TestHtmlTextArea     ta   = new TestHtmlTextArea();
            IPostBackDataHandler pbdh = (ta as IPostBackDataHandler);

            pbdh.LoadPostData("id1", null);
        }
예제 #5
0
        public void IPostBackDataHandler_RaisePostBackEvent()
        {
            TestHtmlInputText it = new TestHtmlInputText("password");

            it.ServerChange += new EventHandler(ServerChange);
            IPostBackDataHandler pbdh = (it as IPostBackDataHandler);

            serverChange = false;
            pbdh.RaisePostDataChangedEvent();
            Assert.IsTrue(serverChange, "ServerChange");
        }
예제 #6
0
        public void IPostBackDataHandler_RaisePostBackEvent()
        {
            TestHtmlTextArea ta = new TestHtmlTextArea();

            ta.ServerChange += new EventHandler(ServerChange);
            IPostBackDataHandler pbdh = (ta as IPostBackDataHandler);

            serverChange = false;
            pbdh.RaisePostDataChangedEvent();
            Assert.IsTrue(serverChange, "ServerChange");
        }
예제 #7
0
        public void IPostBackDataHandler_RaisePostBackEvent()
        {
            TestHtmlInputRadioButton rb = new TestHtmlInputRadioButton();

            rb.ServerChange += new EventHandler(ServerChange);
            IPostBackDataHandler pbdh = (rb as IPostBackDataHandler);

            serverChange = false;
            pbdh.RaisePostDataChangedEvent();
            Assert.IsTrue(serverChange, "ServerChange");
        }
예제 #8
0
        public void IPostBackDataHandler_LoadPostData()
        {
            TestHtmlTextArea ta = new TestHtmlTextArea();

            ta.ID = "id1";
            IPostBackDataHandler pbdh = (ta as IPostBackDataHandler);
            NameValueCollection  nvc  = new NameValueCollection();

            nvc.Add("id1", "mono");
            Assert.IsTrue(pbdh.LoadPostData("id1", nvc), "LoadPostData");
            Assert.AreEqual("mono", ta.Value, "Value");
        }
예제 #9
0
        [Category("NotDotNet")]          // MS throws a NullReferenceException here
        public void IPostBackDataHandler_LoadPostData_IdNull()
        {
            TestHtmlTextArea ta = new TestHtmlTextArea();

            ta.ID = "id1";
            IPostBackDataHandler pbdh = (ta as IPostBackDataHandler);
            NameValueCollection  nvc  = new NameValueCollection();

            nvc.Add("id1", "mono");
            Assert.IsFalse(pbdh.LoadPostData(null, new NameValueCollection()));
            Assert.AreEqual(String.Empty, ta.Value, "Value");
        }
예제 #10
0
        public void IPostBackDataHandler_LoadPostData_WrongId()
        {
            TestHtmlInputRadioButton rb = new TestHtmlInputRadioButton();

            rb.ID = "id1";
            IPostBackDataHandler pbdh = (rb as IPostBackDataHandler);
            NameValueCollection  nvc  = new NameValueCollection();

            nvc.Add("id1", "mono");
            Assert.IsFalse(pbdh.LoadPostData("id2", nvc), "LoadPostData");
            Assert.AreEqual("id1", rb.Value, "Value");
        }
예제 #11
0
        public void IPostBackDataHandler_LoadPostData()
        {
            TestHtmlInputText it = new TestHtmlInputText("password");

            it.ID = "id1";
            IPostBackDataHandler pbdh = (it as IPostBackDataHandler);
            NameValueCollection  nvc  = new NameValueCollection();

            nvc.Add("id1", "mono");
            Assert.IsTrue(pbdh.LoadPostData("id1", nvc), "LoadPostData");
            Assert.AreEqual("mono", it.Value, "Value");
        }
예제 #12
0
        public void TestPostbackHandling()
        {
            HtmlInputHidden      h          = new HtmlInputHidden();
            IPostBackDataHandler p          = (IPostBackDataHandler)h;
            NameValueCollection  collection = new NameValueCollection();
            string key   = "key";
            string value = "Hi i am a value";

            collection [key] = value;
            Assert.IsTrue(p.LoadPostData(key, collection));
            Assert.IsFalse(p.LoadPostData(key, collection));
            Assert.AreEqual(h.Value, value);
        }
예제 #13
0
        public void IPostBackDataHandler_LoadPostData()
        {
            TestHtmlInputRadioButton rb = new TestHtmlInputRadioButton();

            rb.ID = "id1";
            IPostBackDataHandler pbdh = (rb as IPostBackDataHandler);
            NameValueCollection  nvc  = new NameValueCollection();

            nvc.Add("id1", "id1");
            // we didn't change the state of the control
            Assert.IsFalse(pbdh.LoadPostData("id1", nvc), "LoadPostData");
            Assert.AreEqual("id1", rb.Value, "Value");
        }
예제 #14
0
        ///
        /// <summary>
        /// Signals the server control to notify the ASP.NET application that the state of the control has changed.
        /// </summary>
        /// <remarks>
        /// This method forms part of the IPostBackDataHandler interface.  It is the standard mechanism by which
        /// the ASP.NET server tells the server control it has reached the point where all watchers should be
        /// notified that this controls' value (SelectedIndex) has changed.  (It knows if the value has changed
        /// because LoadPostData will have returned True.)
        /// </remarks>
        ///
        public virtual void RaisePostDataChangedEvent()
        {
            OnSelectedIndexChanged(EventArgs.Empty);

            if (_textFieldChanged)
            {
                IPostBackDataHandler textField = _realField;
                textField.RaisePostDataChangedEvent();
                OnTextChanged(EventArgs.Empty);
            }

            return;
        }
예제 #15
0
        public void Postback()
        {
            HtmlInputHidden      h          = new HtmlInputHidden();
            IPostBackDataHandler p          = (IPostBackDataHandler)h;
            NameValueCollection  collection = new NameValueCollection();
            string key   = "key";
            string value = "Hi i am a value";

            collection [key] = value;
            p.LoadPostData(key, collection);

            Assert.AreEqual(h.Value, value, "A1");
        }
예제 #16
0
		public void LoadAndRaise3 ()
		{
			RadioButtonList rbl = new RadioButtonList ();
			rbl.Items.Add (new ListItem ("Uno", "1"));
			rbl.Items.Add (new ListItem ("Dos", "2"));
			rbl.Items.Add (new ListItem ("Tres", "3"));
			rbl.SelectedIndex = 2;
			NameValueCollection nvc = new NameValueCollection ();
			nvc ["XXX"] = "blah";

			IPostBackDataHandler handler = (IPostBackDataHandler) rbl;
			Assert.AreEqual (false, handler.LoadPostData ("XXX", nvc), "#01");
		}
예제 #17
0
		public void LoadAndRaise2 ()
		{
			RadioButtonList rbl = new RadioButtonList ();
			rbl.Items.Add (new ListItem ("Uno", "1"));
			rbl.Items.Add (new ListItem ("Dos", "2"));
			rbl.Items.Add (new ListItem ("Tres", "3"));
			rbl.SelectedIndex = 2;
			NameValueCollection nvc = new NameValueCollection ();
			nvc ["XXX"] = "2";

			IPostBackDataHandler handler = (IPostBackDataHandler) rbl;
			Assert.AreEqual (true, handler.LoadPostData ("XXX", nvc), "#01");
			rbl.SelectedIndexChanged += new EventHandler (OnSelected);
			event_called = false;
			handler.RaisePostDataChangedEvent ();
			Assert.AreEqual (true, event_called, "#02");
			Assert.AreEqual ("2", rbl.SelectedValue, "#03");
		}
예제 #18
0
 // workaround for std ListControl LoadPostData
 void LoadListControlPostDataOnCallback(ListControl control)
 {
     if (!Grid.IsEditing)
     {
         return;
     }
     foreach (ListItem item in control.Items)
     {
         item.Selected = false;
     }
     foreach (string key in Request.Params.AllKeys)
     {
         IPostBackDataHandler dataHandler = control as IPostBackDataHandler;
         if (key.StartsWith(control.UniqueID))
         {
             dataHandler.LoadPostData(key, Request.Params);
         }
     }
 }