public void OnClickAttributeWithSpecials()
        {
#if NET_4_0
            string origHtml  = "alert('<&');";
            string origHtml2 = "alert('<&');";
#else
            string origHtml  = "alert('&lt;&amp;');";
            string origHtml2 = "alert('<&');";
#endif

            StringWriter   sw = new StringWriter();
            HtmlTextWriter tw = new HtmlTextWriter(sw);

            HtmlInputButtonPoker p = new HtmlInputButtonPoker();
            p.Page = new Page();
            p.Attributes["onclick"] = "alert('<&');";
            p.DoRenderAttributes(tw);
            string str   = sw.ToString();
            int    found = str.IndexOf(origHtml);
            Assert.IsTrue(found >= 0, "#01");
            p.ServerClick += new EventHandler(EmptyHandler);
            sw             = new StringWriter();
            tw             = new HtmlTextWriter(sw);
            p.DoRenderAttributes(tw);
            str   = sw.ToString();
            found = str.IndexOf(origHtml2);
            Assert.IsTrue(found >= 0, "#02" + str);
        }
Example #2
0
        public void RenderAttributes()
        {
            StringWriter   sw = new StringWriter();
            HtmlTextWriter tw = new HtmlTextWriter(sw);

            HtmlInputButtonPoker p = new HtmlInputButtonPoker();

            p.Page = new Page();

            p.CausesValidation = false;
#if NET_2_0
            p.ValidationGroup = "VG";

            Assert.AreEqual(3, p.Attributes.Count, "A1");
#else
            Assert.AreEqual(2, p.Attributes.Count, "A1");
#endif

            tw.WriteBeginTag("dummy");
            p.DoRenderAttributes(tw);
            tw.Write('>');
#if NET_2_0
            HtmlDiff.AssertAreEqual("<dummy name type=\"button\" ValidationGroup=\"VG\" />", sw.ToString(), "A2");
#else
            HtmlDiff.AssertAreEqual("<dummy name type=\"button\" />", sw.ToString(), "A2");
#endif
        }
        public void RenderOnclick3()
        {
            HtmlInputButtonPoker it = new HtmlInputButtonPoker("submit");

            it.ID           = "id1";
            it.ServerClick += new EventHandler(EmptyHandler);
            string rendered = it.RenderToString();

            Assert.IsTrue(rendered.IndexOf("onclick") == -1, "#01");
        }
        public void CleanProperties()
        {
            HtmlInputButtonPoker p = new HtmlInputButtonPoker();

            p.CausesValidation = false;
            Assert.IsFalse(p.CausesValidation, "A1");

            p.CausesValidation = true;
            Assert.IsTrue(p.CausesValidation, "A2");

            p.CausesValidation = false;
            Assert.IsFalse(p.CausesValidation, "A3");
        }
        public void ViewState()
        {
            HtmlInputButtonPoker p = new HtmlInputButtonPoker();

            p.CausesValidation = false;
            p.ValidationGroup  = "VG";
            object s = p.SaveState();
            HtmlInputButtonPoker copy = new HtmlInputButtonPoker();

            copy.LoadState(s);

            Assert.IsFalse(copy.CausesValidation, "A1");
            Assert.AreEqual("VG", p.ValidationGroup, "A2");
        }
        public void RenderOnclick2()
        {
            Page page = new Page();

            page.EnableEventValidation = false;
            HtmlInputButtonPoker it = new HtmlInputButtonPoker("button");

            page.Controls.Add(it);
            it.ID           = "id1";
            it.ServerClick += new EventHandler(EmptyHandler);
            string rendered = it.RenderToString();

            Assert.IsTrue(rendered.IndexOf("onclick") != -1, "#01");
        }
Example #7
0
        public void RenderOnclick4()
        {
            Page page = new Page();

#if NET_2_0
            page.EnableEventValidation = false;
#endif
            HtmlInputButtonPoker it = new HtmlInputButtonPoker("submit");
            page.Controls.Add(it);
            it.ID           = "id1";
            it.ServerClick += new EventHandler(EmptyHandler);
            string rendered = it.RenderToString();
            Assert.IsTrue(rendered.IndexOf("onclick") != -1, "#01");
            Assert.IsTrue(rendered.IndexOf("__doPostBack") != -1, "#02");
            Assert.IsTrue(rendered.IndexOf("type=\"submit\"") != -1, "#03");
        }
Example #8
0
        public void RenderOnclick5()
        {
            Page page = new Page();

#if NET_2_0
            page.EnableEventValidation = false;
#endif
            RequiredFieldValidator val = new RequiredFieldValidator();
            val.ControlToValidate = "id1";
            page.Validators.Add(val);
            HtmlInputButtonPoker it = new HtmlInputButtonPoker("submit");
            page.Controls.Add(it);
            it.ID           = "id1";
            it.ServerClick += new EventHandler(EmptyHandler);
            string rendered = it.RenderToString();
            Assert.IsTrue(rendered.IndexOf("onclick") != -1, "#01");
        }
        public void OnClickAttribute()
        {
            StringWriter   sw = new StringWriter();
            HtmlTextWriter tw = new HtmlTextWriter(sw);

            HtmlInputButtonPoker p = new HtmlInputButtonPoker();

            p.Page = new Page();
            p.DoRenderAttributes(tw);
            string str   = sw.ToString();
            int    found = str.IndexOf("onclick");

            Assert.AreEqual(-1, found, "#01");
            p.ServerClick += new EventHandler(EmptyHandler);
            sw             = new StringWriter();
            tw             = new HtmlTextWriter(sw);
            p.DoRenderAttributes(tw);
            str   = sw.ToString();
            found = str.IndexOf("onclick");
            Assert.IsTrue(found >= 0, "#02");
        }
		public void Defaults ()
		{
			HtmlInputButtonPoker p = new HtmlInputButtonPoker ();

			Assert.IsTrue (p.CausesValidation, "A1");
		}
		public void RenderOnclick5 ()
		{
			Page page = new Page ();
#if NET_2_0
			page.EnableEventValidation = false;
#endif
			RequiredFieldValidator val = new RequiredFieldValidator ();
			val.ControlToValidate = "id1";
			page.Validators.Add (val);
			HtmlInputButtonPoker it = new HtmlInputButtonPoker ("submit");
			page.Controls.Add (it);
			it.ID = "id1";
			it.ServerClick += new EventHandler (EmptyHandler);
			string rendered = it.RenderToString ();
			Assert.IsTrue (rendered.IndexOf ("onclick") != -1, "#01");
		}
		public void RenderOnclick4 ()
		{
			Page page = new Page ();
#if NET_2_0
			page.EnableEventValidation = false;
#endif
			HtmlInputButtonPoker it = new HtmlInputButtonPoker ("submit");
			page.Controls.Add (it);
			it.ID = "id1";
			it.ServerClick += new EventHandler (EmptyHandler);
			string rendered = it.RenderToString ();
			Assert.IsTrue (rendered.IndexOf ("onclick") != -1, "#01");
			Assert.IsTrue (rendered.IndexOf ("__doPostBack") != -1, "#02");
			Assert.IsTrue (rendered.IndexOf ("type=\"submit\"") != -1, "#03");
		}
		public void RenderOnclick3 ()
		{
			HtmlInputButtonPoker it = new HtmlInputButtonPoker ("submit");
			it.ID = "id1";
			it.ServerClick += new EventHandler (EmptyHandler);
			string rendered = it.RenderToString ();
			Assert.IsTrue (rendered.IndexOf ("onclick") == -1, "#01");
		}
		public void OnClickAttributeWithSpecials ()
		{
			StringWriter sw = new StringWriter ();
			HtmlTextWriter tw = new HtmlTextWriter (sw);

			HtmlInputButtonPoker p = new HtmlInputButtonPoker ();
			p.Page = new Page ();
			p.Attributes["onclick"] = "alert('<&');";
			p.DoRenderAttributes (tw);
			string str = sw.ToString ();
			int found = str.IndexOf ("alert('&lt;&amp;');");
			Assert.IsTrue (found >= 0, "#01");
			p.ServerClick += new EventHandler (EmptyHandler);
			sw = new StringWriter ();
			tw = new HtmlTextWriter (sw);
			p.DoRenderAttributes (tw);
			str = sw.ToString ();
			found = str.IndexOf ("alert('&lt;&amp;');");
			Assert.IsTrue (found >= 0, "#02" + str);
		}
		public void OnClickAttribute ()
		{
			StringWriter sw = new StringWriter ();
			HtmlTextWriter tw = new HtmlTextWriter (sw);

			HtmlInputButtonPoker p = new HtmlInputButtonPoker ();
			p.Page = new Page ();
			p.DoRenderAttributes (tw);
			string str = sw.ToString ();
			int found = str.IndexOf ("onclick");
			Assert.AreEqual (-1, found, "#01");
			p.ServerClick += new EventHandler (EmptyHandler);
			sw = new StringWriter ();
			tw = new HtmlTextWriter (sw);
			p.DoRenderAttributes (tw);
			str = sw.ToString ();
			found = str.IndexOf ("onclick");
			Assert.IsTrue (found >= 0, "#02");
		}
		public void RenderAttributes ()
		{
			StringWriter sw = new StringWriter ();
			HtmlTextWriter tw = new HtmlTextWriter (sw);

			HtmlInputButtonPoker p = new HtmlInputButtonPoker ();
			
			p.Page = new Page ();

			p.CausesValidation = false;
#if NET_2_0
			p.ValidationGroup = "VG";

			Assert.AreEqual (3, p.Attributes.Count, "A1");
#else
			Assert.AreEqual (2, p.Attributes.Count, "A1");
#endif

			tw.WriteBeginTag ("dummy");
			p.DoRenderAttributes (tw);
			tw.Write ('>');
#if NET_2_0
			HtmlDiff.AssertAreEqual ("<dummy name type=\"button\" ValidationGroup=\"VG\" />", sw.ToString (), "A2");
#else
			HtmlDiff.AssertAreEqual ("<dummy name type=\"button\" />", sw.ToString (), "A2");
#endif
		}
		public void CleanProperties ()
		{
			HtmlInputButtonPoker p = new HtmlInputButtonPoker ();

			p.CausesValidation = false;
			Assert.IsFalse (p.CausesValidation, "A1");

			p.CausesValidation = true;
			Assert.IsTrue (p.CausesValidation, "A2");

			p.CausesValidation = false;
			Assert.IsFalse (p.CausesValidation, "A3");
		}
        public void Defaults()
        {
            HtmlInputButtonPoker p = new HtmlInputButtonPoker();

            Assert.IsTrue(p.CausesValidation, "A1");
        }
Example #19
0
		public void ViewState ()
		{
			HtmlInputButtonPoker p = new HtmlInputButtonPoker ();
			p.CausesValidation = false;
			p.ValidationGroup = "VG";
			object s = p.SaveState();
			HtmlInputButtonPoker copy = new HtmlInputButtonPoker ();
			copy.LoadState (s);

			Assert.IsFalse (copy.CausesValidation, "A1");
			Assert.AreEqual ("VG", p.ValidationGroup, "A2");
		}
		public void RenderOnclick2 ()
		{
			Page page = new Page ();
			page.EnableEventValidation = false;
			HtmlInputButtonPoker it = new HtmlInputButtonPoker ("button");
			page.Controls.Add (it);
			it.ID = "id1";
			it.ServerClick += new EventHandler (EmptyHandler);
			string rendered = it.RenderToString ();
			Assert.IsTrue (rendered.IndexOf ("onclick") != -1, "#01");
		}