Click here to Skip to main content
15,861,172 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
a program to display "Welcome to ASP.NET" 8 times in increasing font sizes using ASP.NET..

how can i do this thing..
Posted
Comments
sam9918 7-Oct-12 6:02am    
i have tried solving like this...



<%
HelloWorldLabel.Text = "Welcome to ASP.NET";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label runat="server" id="HelloWorldLabel">
</div>
</form>
</body>
</html>


but i am not able to increase the font of the label and that to only 8 times
Zoltán Zörgő 7-Oct-12 7:48am    
"using asp.net" is not enough requirement. Since asp.net is a web application framework, you make web application - a single web page in your case. So you can make it without any code just by writing html tags, or you can make it with javascript without any server side code. So how exactly your homework requirement looks like?
sam9918 7-Oct-12 8:46am    
well the homework is finished..

but if you have any other solutions other than the 2 mentioned in the solutions then please do post it...

A label has a font - so if you want to use labels, you have to use 8 of them in order to get 8 different sizes.

There are a number of ways to do this: I would use perhaps spans?
SQL
<span style="font-size:10px">Hello!</span>
Which will print as:
Hello!
Whereas
SQL
<span style="font-size:20px">Hello!</span>
Will print as:
Hello!

However, if you are trying to produce a program to do this, you will probably need to write code in the codebehind to generate the spans. It's not difficult, but as it's your homework, I think you have enough clues to get started, don't you? :laugh:
 
Share this answer
 
Comments
sam9918 7-Oct-12 6:20am    
thnks for the suggestion... :)
OriginalGriff 7-Oct-12 6:23am    
You're welcome!
sam9918 7-Oct-12 6:24am    
but still i am not able to do the same...

as i am using the for loop for doing the thing
but its not working..

or i have to use 8 spans and do my thing??
and make 1 span visible for a time and 2 span for the other time??
OriginalGriff 7-Oct-12 6:38am    
Web sites are static things: the data received by the browser is a string of HTML, which doesn't change once the page is loaded.
So if you need eight text sizes, you need to send 8 spans.
So your for loop in the codebehind needs to construct eight spans, and feed them to the web page. (It's not as difficult as it sounds - look in your lecture notes!)
sam9918 7-Oct-12 6:37am    
well finally i have done... :) :D
C#
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:literal ID="Literal1" runat="server" Visible="true">
</asp:literal>
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick" >
</asp:Timer>
<asp:Label ID="Label1" runat="server" Text="">
<asp:Label>
<asp:Label ID="Label2" runat="server" Text="">
<asp:Label>
<asp:Label ID="Label3" runat="server" Text="">
<asp:Label>
<asp:Label ID="Label4" runat="server" Text="">
<asp:Label>
<asp:Label ID="Label5" runat="server" Text="">
<asp:Label>
<asp:Label ID="Label6" runat="server" Text="">
<asp:Label>
<asp:Label ID="Label7" runat="server" Text="">
<asp:Label>

In Code behind file you do this.

C#
public partial class page1 : System.Web.UI.Page
    {
       static int i = 1;
        protected void Page_Load(object sender, EventArgs e)
        {
ViewState["key"] = Literal1.Text;
            Label1.Text = ViewState["key"].ToString();
Label2.Text = ViewState["key"].ToString();
Label3.Text = ViewState["key"].ToString();
Label4.Text = ViewState["key"].ToString();
Label5.Text = ViewState["key"].ToString();
Label6.Text = ViewState["key"].ToString();
Label7.Text = ViewState["key"].ToString();            

        }

        protected void Timer1_Load(object sender, EventArgs e)
        {

        }

        protected void Timer1_Tick(object sender, EventArgs e)
        {
            
            Literal1.Text="<h"+i+">"+"Hello"+"<h"+i+">"+"\n";

            if (i == 8)
            {

                i = 0;
            }
            else { i++; }
        }
    }


So,for every 1s you can find the font size changing
 
Share this answer
 
Comments
sam9918 7-Oct-12 8:42am    
thnks for the such a good solution...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900