PDA

View Full Version : [CLOSED] how to add content of fieldcontainer in codebehind?



hdsoso
May 15, 2014, 4:49 PM
<ext:FieldContainer ID="Container1" AnchorHorizontal="100%" runat="server" FieldLabel="验证码">
<Content>
<obout:CaptchaImage ID="Captcha1" runat="server" RelativeImageUrl="false" />
<a href="javascript:$find('<%=Captcha1.ClientID %>').getNewImage();">看不清?</a>
</Content>
</ext:FieldContainer>

how to do above in codebehind?



<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm44.aspx.cs" Inherits="extdemo.test.WebForm44" %>

<%@ Import Namespace="Ext.Net" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
CreateLoginWindow();
}
private void CreateLoginWindow()
{
var window = new Ext.Net.Window
{
Title = "用户登录",
ID = "w_login",
Width = 300,
Modal = true,
Closable = false,

};
var fp = new Ext.Net.FormPanel
{
Padding = 4,
Layout = LayoutType.Anchor.ToString(),

Buttons =
{
new Ext.Net.Button {Text = "取消"},
new Ext.Net.Button {Text = "登录"}
}
};
var tfName = new TextField
{
ID = "tf_uname",
FieldLabel = "用户名",
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 60
};
var tfPass = new TextField
{
ID = "tf_pass",
FieldLabel = "密码",
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 60
};
fp.Items.Add(tfName);
fp.Items.Add(tfPass);
var fc = new FieldContainer();
// fc.Content=
fp.Items.Add(fc);
window.Items.Add(fp);
this.Form.Controls.Add(window);
}

</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server"></ext:ResourceManager>
</form>
</body>
</html>

Daniil
May 15, 2014, 6:21 PM
Hi @hdsoso,

Please put the controls into a FieldContainer's ContentControls.

hdsoso
May 16, 2014, 9:01 AM
Hi @hdsoso,

Please put the controls into a FieldContainer's ContentControls.

what about a tag?

Daniil
May 16, 2014, 11:11 AM
You can use a GenericHtmlControl.
http://stackoverflow.com/questions/1799158/asp-net-programmatically-add-a-span-tag-not-label-control