Esempio n. 1
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");
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public void IPostBackDataHandler_LoadPostData_NullCollection()
        {
            TestHtmlInputText    it   = new TestHtmlInputText("password");
            IPostBackDataHandler pbdh = (it as IPostBackDataHandler);

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

            pbdh.LoadPostData("id1", null);
        }
Esempio n. 5
0
        public void IPostBackDataHandler_LoadPostData_NullCollection()
        {
            TestHtmlInputRadioButton rb   = new TestHtmlInputRadioButton();
            IPostBackDataHandler     pbdh = (rb as IPostBackDataHandler);

            pbdh.LoadPostData("id1", null);
        }
Esempio n. 6
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");
        }
Esempio n. 7
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");
        }
Esempio n. 8
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");
        }
Esempio n. 9
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");
        }
		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");
		}
Esempio n. 11
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");
        }
Esempio n. 12
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");
        }
		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");
		}
Esempio n. 14
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);
         }
     }
 }