ERLEDIGT
JA
JA
ANTWORTEN
1
1
ZUGRIFFE
266
266
EMPFEHLEN
-
Hallo.
Jetzt könnt ich ausflippen. Ich mach ein ganz einfache Sach
Ich will einem control im code ein control aus der site zuweisen.
Das wollte ich mit findControl machen. Aber das bringtnull.
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<tr> <td style="width: 48px"> 08.30-09.15</td> <td style="width: 136px"> <asp:TextBox ID=[B]"tbl1[/B]" runat="server" Height="16px" Width="61px" AutoPostBack="True"></asp:TextBox> <asp:ImageButton ID="img1" runat="server" Height="16px" ImageUrl="~/App_Themes/Icons/icons/Edit.png" Width="16px" onclick="imgb_Click" /> <asp:DropDownList ID="ddll1" runat="server" Height="16px" Width="62px" Visible="False"> </asp:DropDownList> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr>
jetzt der 'Code'
Code :1 2 3 4 5 6 7 8 9 10
[B]TextBox myControl1 = FindControl("tbl1") as TextBox ; [/B] if (myControl1 != null) { Control myControl2 = myControl1.Parent; Response.Write("Parent of the text box is : " + myControl2.ID); } else { Response.Write("Control not found"); }
Ich weiss dass die Textbox da ist. Wieso findet der Code sie nicht?
ciao und danke
-
Wow! so viele Antworten

Aber ich hab die Antwort inzwischen selbst gefunden:
Und ich will sie Euch nicht vorenthalten, damit nicht jeder drüber stolpert.
wenn man die site in einer Masterpage hat (war bei mir der Fall) muss ich auch erst über
das ContentPlaceHolder-Control gehen. Dh. ich muss das findcontrol im master-control stattfinden lassen
in meinem Fall heisst das also:
Code :1 2
ContentPlaceHolder c = Master.FindControl("MainContent") as ContentPlaceHolder; TextBox tbf = c.FindControl(sTbf) as TextBox;
ciao
Ähnliche Themen
-
Problem mit FindControl
Von chrisfisch im Forum .NET DatenverwaltungAntworten: 0Letzter Beitrag: 27.07.10, 08:41 -
Kann mir mal einer sagen wie man FindControl benutzt
Von AppleSeed im Forum .NET DatenverwaltungAntworten: 8Letzter Beitrag: 01.10.07, 10:22 -
Ich flipp aus Hair and Fur
Von der_karl im Forum 3D Studio MaxAntworten: 5Letzter Beitrag: 05.09.07, 01:38 -
Wer hat noch Mac OS X 10.2.8?
Von RobertGrund im Forum Mac OSAntworten: 2Letzter Beitrag: 07.11.05, 09:47 -
Grafiktabletts - noch großer, noch besser, noch schneller ?
Von essence im Forum PhotoshopAntworten: 14Letzter Beitrag: 08.12.03, 21:31





Zitieren
Login





