Issue
I'm dynamically creating Controls and adding them to a Web Part.
When I do this:
this.Controls.Add(new LiteralControl("<br />"));
Button btnSave = new Button();
btnSave.Text = "Save";
btnSave.Click += new EventHandler(btnSave_Click);
this.Controls.Add(btnSave);
this.Controls.Add(new LiteralControl("<br />")); // <= this does nothing
...the button sits down on the very bottom of the web part:

(note that adding a "br" is ignored)
If I add this:
btnSave.BorderWidth = 6;
...it does provide a border around the button, but it's not the same color as the background -- it's black, as you can see:

How can I add some space below the button without the border having a color other than the background?
UPDATE
I wanted to try the btnSave.Style.MarginBottom code suggested, but there is no "MarginBottom" subproperty of the Button's Style property, as can be seen here:

UPDATE 2
When I tried Mohammad's latest suggestion:
btnSave.BorderColor = this.BorderColor;
...I got, "The type 'System.Drawing.Color' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing. . ."
So I tried that:
using System.Drawing;
...but trying to compile resulted in: "The type or namespace name 'Drawing' does not exist in the namespace 'System' (are you missing an assembly reference?)"
Solution
This is the ticket (inspired by a code snippet (using "div") here:
//this.Controls.Add(new LiteralControl("<br />")); // <= this does nothing
HtmlGenericControl breakingSpace = new HtmlGenericControl("br");
this.Controls.Add(breakingSpace);
Answered By - B. Clay Shannon-B. Crow Raven
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.