PDA

View Full Version : [CLOSED] Get Dynamic TextField Text...



gs_user
Apr 20, 2012, 7:09 AM
Hi,

I dynamic built TextFile,Image in Panel,
When save button click, I have to get TextField text to my db
how can i get the TextFile text ???

pageload


for (int i = 0; i < mytmp.Rows.Count; i++)
{
Ext.Net.Panel mypanel = new Ext.Net.Panel();
mypanel.Title = mytmp.Rows[i]["col1"].ToString();
Ext.Net.Image myimg = new Ext.Net.Image();
myimg.ImageUrl = mytmp.Rows[i]["col2"].ToString() + ".jpg";
mysignlist.Add(mytmp.Rows[i]["col1"].ToString() + " " + mytmp.Rows[0]["col2"].ToString());
myimg.Hidden = false;
myimg.Width = 80;
myimg.Height = 80;
mypanel.Add(myimg);
Ext.Net.TextField myfield = new Ext.Net.TextField();
myfield.Text = mytmp.Rows[0]["col2"].ToString();
myfield.Hidden = true;
mypanel.Add(myfield);
Panel17.Add(mypanel);
}

thanks for your help.

Daniil
Apr 20, 2012, 10:33 AM
Hi,

Please clarify where do you create that TextField? During DirectEvent or Page_Load? Do you recreate that TextField during each DirectEvent?

geoffrey.mcgill
Apr 20, 2012, 6:29 PM
Another option that might be helpful in this scenario would be to just loop through all the submitted form Name+Value pairs.

I don't think re-creating the controls upon each request is practical for this type of scenario.


this.Request.Form


Another option is using X.GetCmp<TextField>("ID_HERE"), which will attempt to create a proxy instance of the Field, based upon the values sumitted in the Request.

Hope this helps.

gs_user
Apr 23, 2012, 1:09 AM
I create TextField at Page_Load


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["status"] == "INS")
{
DataTable mytmp;

if (mytmp.Rows.Count > 0)
{
for (int i = 0; i < mytmp.Rows.Count; i++)
{
Ext.Net.Panel mypanel = new Ext.Net.Panel();
mypanel.Title = mytmp.Rows[i]["col1"].ToString();
Ext.Net.Image myimg = new Ext.Net.Image();
myimg.ImageUrl = mytmp.Rows[i]["col2"].ToString() + ".jpg";
mysignlist.Add(mytmp.Rows[i]["col3"].ToString() + " " + mytmp.Rows[0]["col4"].ToString());
myimg.Hidden = false;
myimg.Width = 80;
myimg.Height = 80;
mypanel.Add(myimg);
Ext.Net.TextField myfield = new Ext.Net.TextField();
myfield.Text = mytmp.Rows[0]["col5"].ToString();
myfield.Hidden = true;
mypanel.Add(myfield);
Panel17.Add(mypanel);
}

}
}
}


I don't recreate that TextField during DirectEvent



Hi,

Please clarify where do you create that TextField? During DirectEvent or Page_Load? Do you recreate that TextField during each DirectEvent?

geoffrey.mcgill
Apr 23, 2012, 1:44 AM
My recommendations above are probably the best way to approach this problem.

gs_user
Apr 23, 2012, 3:54 AM
I still can't get text
I do sothing wrong????
please help me, thank you


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["status"] == "INS")
{

DataTable mytmp;
if (mytmp.Rows.Count > 0)
{
for (int i = 0; i < mytmp.Rows.Count; i++)
{
Ext.Net.Panel mypanel = new Ext.Net.Panel();
mypanel.Title = mytmp.Rows[i]["col1"].ToString();
Ext.Net.Image myimg = new Ext.Net.Image();
myimg.ImageUrl = mytmp.Rows[i]["col1"].ToString() + ".jpg";
mysignlist.Add(mytmp.Rows[i]["col1"].ToString() + " " + mytmp.Rows[0]["col1"].ToString());
myimg.Hidden = false;
myimg.Width = 80;
myimg.Height = 80;
mypanel.Add(myimg);
Ext.Net.TextField myfield = new Ext.Net.TextField();
myfield.ID = "meet4";
myfield.Text = mytmp.Rows[0]["col1"].ToString();
//myfield.Hidden = true;
mypanel.Add(myfield);
Panel17.Add(mypanel);

}
}
}
}




protected void Save_Data(object sender, DirectEventArgs e)
{
TextField MyF = X.GetCmp<TextField>("meet4");
mylist.Add(MyF.Text);

}




<ext:Panel ID="Panel9" runat="server" Layout="Absolute" Region="Center" Title="" BodyPadding="5" Height ="400">
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="bt_save" runat="server" Text="save" Icon="Disk">
<DirectEvents>
<Click OnEvent="Save_Data">
<EventMask ShowMask="True" Msg="wait..." MinDelay="500" />
</Click>
</DirectEvents>
</ext:Button>

<ext:ToolbarFill ID="ToolbarFill1" runat="server" />
</Items>
</ext:Toolbar>
</TopBar>

</ext:Panel>


My recommendations above are probably the best way to approach this problem.

geoffrey.mcgill
Apr 23, 2012, 4:43 AM
Please wrap your code samples in [CODE] tags. The following posts detail several tips for posting in the forums, see

http://forums.ext.net/showthread.php?3440-Forum-Guidelines-For-Posting-New-Topics

http://forums.ext.net/showthread.php?10205-More-Information-Required

geoffrey.mcgill
Apr 23, 2012, 5:41 AM
Hi,

Based upon the code sample you have posted, your code does appear correct. I cannot see any obvious problems.

I created the following sample which demonstrates the full scenario of building dynamic Fields during a DirectEvent, then getting those dynamic values during a future DirectEvent.

Example


<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" TagPrefix="ext" Namespace="Ext.Net" %>


<script runat="server">
protected void Button1_Click(object sender, DirectEventArgs e)
{
this.FormPanel1.Items.AddRange(new[] {
new TextField { ID = "TextField1", FieldLabel = "Item 1" },
new TextField { ID = "TextField2", FieldLabel = "Item 2" },
new TextField { ID = "TextField3", FieldLabel = "Item 3" },
});


this.FormPanel1.Update();
}


protected void Button2_Click(object sender, DirectEventArgs e)
{
var tpl = "Item 1 : {0}<br />Item 2 : {1}<br />Item 3 : {2}";

var item1 = X.GetCmp<TextField>("TextField1").Text;
var item2 = X.GetCmp<TextField>("TextField2").Text;
var item3 = X.GetCmp<TextField>("TextField3").Text;

X.Msg.Notify("Values", string.Format(tpl, item1, item2, item3)).Show();
}
</script>


<html>
<head>
<title>Ext.NET Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Button runat="server" Text="Create Fields" OnDirectClick="Button1_Click" />
<ext:Button runat="server" Text="Get Values" OnDirectClick="Button2_Click" />


<ext:FormPanel
ID="FormPanel1"
runat="server"
Title="Example"
DefaultAnchor="100%"
Padding="5"
Height="215"
Width="350"
/>
</form>
</body>
</html>

gs_user
Apr 24, 2012, 3:56 AM
It's worked..thank you