Hmmm.... Firstly, that's a very good site. I like it very much and I think David Adams did a fantastic job !
As for your problem, I think it may be due to the fact that the Label control is not a very good container. There are probably a million ways to do this, but a few good options that would work would be to : a) Construct the whole Welcome string dynamically and assign it to the text property of a single Label. b) Use your Labels in the following way : <asp:Label ID="Par" runat="Server" Text="Welcome to my Web page, " /> <asp:Label ID="NameOut" runat="Server" Text="" /> ... and set the NameOut.Text each time the "Style Output" button is clicked. HTH. On Oct 15, 2:38 am, Justin <[EMAIL PROTECTED]> wrote: > Hey everyone, I'm extremely new to the world of ASP.NET. I am > following an online tutorial located > here:http://www.maconstateit.net/tutorials/ASPNET20/default.htm > > and am working on this > tutorialhttp://www.maconstateit.net/tutorials/ASPNET20Assignments/ASPNET02/Th... > > This page is supposed to change the styles of printed text when a > button is pressed. That works fine. My question is, when I press the > button again, the text disappears, and I was wondering why? Theres no > code in there to make the labels (Par and NameOut) not visible or > removes the text. > > Enlightenment will be greatly appreciated. And since I'm very new, > feel free to critique my style, variable names, etc. > > Thanks > > Justin > > Below is my code: > > <code> > > <?xml version="1.0" encoding="UTF-8" ?> > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > > <%@ Import Namespace=System.Drawing %> > > <SCRIPT Runat="Server"> > > Sub Display_Name(sender as Object, e as EventArgs) > If NameIn.Text <> "" Then > NameOut.Text = NameIn.Text > StyleButton.Visible = True > Else > StyleButton.Visible = False > End If > End Sub > > Sub Style_Output(sender as Object, e as EventArgs) > Par.Font.Bold = True > Par.ForeColor = Color.FromName("#6600FF") > NameOut.Font.Bold = True > NameOut.ForeColor = Color.Fromname("Red") > NameOut.Font.Size = FontUnit.Parse("14pt") > NameOut.BackColor = Color.FromName("Yellow") > End Sub > > </SCRIPT> > > <html xmlns="http://www.w3.org/1999/xhtml"> > > <head> > > </head> > > <body> > <form Runat="Server"> > <h2>Dynamic Styles</h2> > <p>Enter your name: > <asp:TextBox id="NameIn" Runat="Server" /> > <asp:Button Text="Enter" OnClick="Display_Name" > Runat="Server" /> > </p> > <p><asp:Label id="Par" Runat="Server"> > Welcome <asp:Label id="NameOut" Runat="Server" /> to > my Web page. > </asp:Label> > </p> > <p><asp:Button id="StyleButton" Text="Style Output" > OnClick="Style_Output" Visible="False" Runat="Server" /> > </p> > </form> > </body> > > </html> > > </code> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/DotNetDevelopment You may subscribe to group Feeds using a RSS Feed Reader to stay upto date using following url <a href="http://feeds.feedburner.com/DotNetDevelopment"> http://feeds.feedburner.com/DotNetDevelopment</a> -~----------~----~----~----~------~----~------~--~---
