Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Setting form properties in code
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00873706
Message ID:
00874300
Vues:
16
Hi Doru,

I appologize. I gave you code for WinForms, not WebForms. To change the color of the page, you set the Body.Attributes["bgcolor"] to the color to use. Here is a working example of how to do this:
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>
   <script runat="server">
      void SubmitBtn_Click(object Source, EventArgs e) 
      {
         Body.Attributes["bgcolor"] = ColorSelect.Value;
      }
   </script>
</head>

<body id=Body runat="server">

   <h3>Updating Styles with the HtmlGenericControl</h3>

   <form runat="server">
      <p>
      Select a background color for the page: <p>
      <select id="ColorSelect" runat="server">
         <option>White</option>
         <option>Wheat</option>
         <option>Gainsboro</option>
         <option>LemonChiffon</option>
      </select>
      <input type="submit" runat="server" 
             Value="Apply" OnServerClick="SubmitBtn_Click">
   </form>
</body>
</html>
>Hi Cathi,
>Where do I put that code and what object is 'this' pointing to? I wanted to have code in the option button to change the color of the page.
>
>>Hi Doru,
>>
>>To change the background color of the form, you would do the following:
>>
>>
>>this.BackColor = Color.Blue
>>
>>
>>>I created a C# web form in VS.NET and set the background color of the form to blue. I added a 3 buttons option group and tryied to change the color of the form when selecting an option... I thought it would be something like this.parent.bgcolor = rgb(), but it seems that this is as far as the moon from what I wanted. I tryied to lookup how do you set proprties in code in C#, but found zero so far.
>>>I am at the begining of a C# for web in 21 days and some other C# and ASP.NET reading, but do I have to go from start to end before I can do the simplest things?
>>>I hesitated about opening this thread in C#, maybe chatter would've fit better given the stage that I am in with dotnet...
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform