Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

dynamic textbox name problem

[es] :: .NET :: dynamic textbox name problem

[ Pregleda: 1481 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Infinite Dreams

Član broj: 26376
Poruke: 7
*.beotel.net



Profil

icon dynamic textbox name problem14.05.2004. u 14:18 - pre 241 meseci
imam textboxove na aspx stranici i svi se zovu isto samo sto se iz baze uzima id i dodaje na ime txtText i dobijaju se imena textboxova... problem tu nastaje kada hocu da uzmem vrednost iz takvog textboxa... probao sam to da uradim i napocetku je radilo, ali sada nece... ono sto me zanima jeste da li ja mogu to na neki nacin da uradim, a da to nije submit forme posto ovo radim sa dugmetom slikom koju kada kliknes ides na tu istu stranu i uzimas Request.Form("txtText" & id_iz_baze), ali to nece da radi... ako imate neku ideju vise je nego dobro dosla....
 
Odgovor na temu

jablan

Član broj: 8286
Poruke: 4541



+710 Profil

icon Re: dynamic textbox name problem14.05.2004. u 15:11 - pre 241 meseci
Mani se Request.Form-a. Ovo hoćeš:

WebForm1.aspx.cs:
Code:

using System;
using System.Collections;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace WebApplication1
{
    /// <summary>
    /// Summary description for WebForm1.
    /// </summary>
    public class WebForm1 : System.Web.UI.Page
    {
        protected System.Web.UI.WebControls.ImageButton ImageButton1;
        protected System.Web.UI.WebControls.PlaceHolder PlaceHolder1;
        protected System.Web.UI.WebControls.Label Label1;

        protected ArrayList al = new ArrayList();
    
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (IsPostBack) 
            {
                for (int i = 0; i < 10; i++) 
                {
                    if (al[i] is TextBox)
                        Label1.Text += ((TextBox)al[i]).Text;
                }
            }
        }

        private void Page_Init(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
            for (int i = 0; i < 10; i++) 
            {
                TextBox tb = new TextBox();
                tb.ID = "tb" + i.ToString();
                al.Add(tb);
                PlaceHolder1.Controls.Add(tb);
            }
        }


        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }
        
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {    
            this.Load += new System.EventHandler(this.Page_Load);
            this.Init += new System.EventHandler(this.Page_Init);

        }
        #endregion
    }
}


WebForm1.aspx:
Code:

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
 Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
    <HEAD>
        <title>WebForm1</title>
        <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
        <meta name="CODE_LANGUAGE" Content="C#">
        <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <asp:ImageButton id="ImageButton1" runat="server" 
ImageUrl="jimihendrix.gif">
</asp:ImageButton>
            <asp:PlaceHolder id="PlaceHolder1" runat="server">
</asp:PlaceHolder>
            <asp:Label id="Label1" runat="server">Label</asp:Label>
        </form>
    </body>
</HTML>

 
Odgovor na temu

Infinite Dreams

Član broj: 26376
Poruke: 7
*.beotel.net



Profil

icon Re: dynamic textbox name problem14.05.2004. u 16:46 - pre 241 meseci
malo komplikovano izgleda... ja sam mislio da to moze jednostavnije, a i malo mi je nejasno posto je C#, ali pousacu da ga razumem...

a jos jedno pitanje samo vezano za ASP kako bi to isto mogao da uradim na ASP stranicama?
 
Odgovor na temu

[es] :: .NET :: dynamic textbox name problem

[ Pregleda: 1481 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.