Καλημέρα...Έχω τα εξής μικρά snippet :
Φτιάχνει ένα TextBox το οποίο πρόσθεσα και ένα Tag.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| [
AspNetHostingPermission(SecurityAction.Demand,Level = AspNetHostingPermissionLevel.Minimal),
AspNetHostingPermission(SecurityAction.InheritanceDemand,Level = AspNetHostingPermissionLevel.Minimal),
DefaultProperty("Text"),
ToolboxData("<{0}:EnTextBox runat=\"server\"> </{0}:EnTextBox>")
]
public class EnTextBox : TextBox {
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
this.Style[HtmlTextWriterStyle.TextAlign]= "right";
this.Style[HtmlTextWriterStyle.Position] = "relative";
}
private string tag = "";
public string Tag {
get { return this.tag;}
set { this.tag = value;}
}
} |
Μου δουλεύει!
Εχω τώρα αυτό, το οποίο "παντρέυει ένα label, ένα textbox κάτω άπο ένα control για να το εισάγω σε μια φόρμα και να το έχω σαν προκάτ. :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
| [
AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal),
AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal),
DefaultProperty("Text"),
ToolboxData("<{0}:LabelTextBox runat=\"server\"> </{0}:LabelTextBox>")
]
public class LabelTextBox : System.Web.UI.Control {
Label lbl = null;
EnTextBox txt = null;
public string Markquee { get { if (lbl != null) return lbl.Text; else return ""; } set { if (lbl != null) lbl.Text = value; else { lbl = new Label(); lbl.Style[HtmlTextWriterStyle.FontWeight] = "bold"; lbl.Text = value; }; } }
public string Tag { get { if (txt != null) return txt.Tag; else return ""; } set { if (txt != null) txt.Tag = value; else { txt = new EnTextBox(); txt.Tag = value; }; } }
public string Text { get { if (txt != null) return txt.Text; else return ""; } set { if (txt != null) txt.Text = value; else { txt = new EnTextBox(); txt.Text = value; }; } }
public LabelTextBox() {
lbl = new Label();
lbl.Style[HtmlTextWriterStyle.FontWeight] = "bold";
txt = new EnTextBox();
}
protected override void OnInit(EventArgs e) {
lbl.Style[HtmlTextWriterStyle.FontWeight] = "bold";
}
protected override void Render(HtmlTextWriter writer) {
base.Render(writer);
}
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
lbl.Style[HtmlTextWriterStyle.FontStyle] = "bold";
}
} |
.....
Και αυτό δεν μπορώ να καταλάβω τι κάνω λάθος.
Φταίει το ότι κάνω επέκταση του Control ? Μήπως έπρεπε να χρησιμοποιήσω κάτι άλλο. Σημείση στo GUI, βλέπω ότι σχεδιάζω και δείχνει να ρεντάρετε μια χαρά. Όταν τρέχω το κώδικα, δεν βλέπω τίποτα...και ούτε exception...
Καμιά ιδέα;