sidnijs Posted July 29, 2006 Posted July 29, 2006 :confused: I have script and this script have to get information from textbox which is in a LoginView! <script language="vb" runat="server"> .... ............. = TextBox1.Text .... </script> <html.... .... <asp:LoginView ID="LoginView1" runat="server"> <AnonymousTemplate> <asp:TextBox ID="TextBox1" runat="server" Width="305px"></asp:TextBox> </AnonymousTemplate> </asp:LoginView> </html> But there is an error whet I run my page... :( "TextBox1 not declared" <--- error in script! WHY????? I have tried to write "LoginView1.TextBox1.Text", "LoginView1.AnonymousTemplate.TextBox1.Text" and others... :( :confused: Quote
Administrators PlausiblyDamp Posted July 29, 2006 Administrators Posted July 29, 2006 You will need to use the FindControl method of the LoginView control - something like ((TextBox)LoginView1.FindControl("TextBox1")).Text = "Test"; although you need to be aware that if the user is logged in this will return null. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
sidnijs Posted July 29, 2006 Author Posted July 29, 2006 tnx :) i will try "convert" your suggestion ti VB... :) Quote
sidnijs Posted July 29, 2006 Author Posted July 29, 2006 =/ I still have a problem. LoginView1.FindControl(textbox1).Text The name 'textbox1' is not declared! =/ i don't understand!!!! :confused: p.S. Textbox is in ''AnonymousTemplate'' ---> and i'm not logged in... Quote
Administrators PlausiblyDamp Posted July 29, 2006 Administrators Posted July 29, 2006 DirectCast(LoginView1.FindControl("TextBox1"), TextBox).Text = "Test" Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
sidnijs Posted July 30, 2006 Author Posted July 30, 2006 Object reference not set to an instance of an object. ??? :confused: Quote
Administrators PlausiblyDamp Posted July 30, 2006 Administrators Posted July 30, 2006 It will only work if the anonymous template is showing and if you have the control ID exactly right. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
sidnijs Posted July 31, 2006 Author Posted July 31, 2006 ctype (loginview1.findcontrol("Textbox1"), textbox).text ^--- sometimes works!!!! I hate MS programmers!!! :mad: Quote
Administrators PlausiblyDamp Posted July 31, 2006 Administrators Posted July 31, 2006 If ctype works, DirectCast should as well. You need to make sure that when you refer to a control the text is the same including the casing. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.