예제 #1
0
        public string GetHtml()
        {
            HtmlDivision div = new HtmlDivision();
            HtmlImage    img = new HtmlImage();

            img.Attributes.Add("id", Name);
            HtmlScript script = new HtmlScript();

            System.IO.StringWriter js = new System.IO.StringWriter();
            js.Write(string.Format("var images = new Array({0});", Images.Count));
            js.Write(string.Format("var hrefs = new Array({0});", Images.Count));
            int i = 0;

            foreach (var image in Images)
            {
                js.Write(string.Format("images[{0}] = \"{1}\";", i, image.Key));
                js.Write(string.Format("hrefs[{0}] = \"{1}\";", i, image.Value));
                i++;
            }
            //js.Write("$(document).ready(function() { $('{0}').setInterval(function() {}, {}) });");
            script.InnerText = js.ToString();

            // todo: finish this

            return(div.ToHtml());
        }
예제 #2
0
        public Control GetControl()
        {
            HtmlDivision div = new HtmlDivision();

            txtTilte = new TextBox {
                Text = "主题评论", Width = 500
            };
            txtAuthor = new TextBox {
                Text = "匿名用户", Width = 500
            };
            txtText = new TextBox {
                TextMode = TextBoxMode.MultiLine, Width = 500, Height = 150
            };
            lblErrorMessage = new Label {
                Text = "请认真填写评论", ForeColor = System.Drawing.Color.Red, Visible = false
            };
            //CustomValidator cv = new CustomValidator { ForeColor = System.Drawing.Color.Red, ControlToValidate = "txtText"};

            div.Controls.Add(new HtmlSpan {
                InnerText = "标题"
            });
            div.Controls.Add(txtTilte);
            div.Controls.Add(new HtmlBreak());
            div.Controls.Add(new HtmlSpan {
                InnerText = "署名"
            });
            div.Controls.Add(txtAuthor);
            div.Controls.Add(new HtmlBreak());
            div.Controls.Add(new HtmlSpan {
                InnerText = "内容"
            });
            div.Controls.Add(txtText);
            div.Controls.Add(lblErrorMessage);
            div.Controls.Add(new HtmlBreak());

            Button btnPost = new Button {
                Text = "发表评论"
            };

            btnPost.Attributes.Add("id", "btnPost");
            //btnPost.Attributes.Add("onclick", @"if($('textarea').val().length < 6){ event.preventDefault(); $('#btnPost').parent().append('<span style=""color:red"">请认真填写评论。</span>'); }");
            //btnPost.OnClientClick = "if($('textarea').val().length < 6){ event.preventDefault(); $('#btnPost').parent().append('<span style=\"color:red\">请认真填写评论。</span>'); }";
            btnPost.Click += new EventHandler(btnPost_Click);
            div.Controls.Add(btnPost);

            return(div);
        }