Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

Changing DetailsView controls in PreRender will fails on postbacks

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Khafancoder - 11 Jul 2007 21:50 GMT
Hi guys,

i'm trying to change all of page control's (root controls and inner
controls) forecolor in PreRender event.
it works fine but when a postback occures by detailsview command
buttons, it fails...

(i trace the code, it even executes in postbacks but control's
forecolor don't change)

i use this code :

[code]

   protected override void OnPreRender(EventArgs e)
   {
       ChangeColor(this.Controls);

       base.OnPreRender(e);

   }

   private void ChangeColor(ControlCollection controls)
   {

       foreach (Control c in controls)
       {
           if (c.HasControls())
               ChangeColor(c.Controls);
           else if (c is DetailsView)
           {
               DetailsView view = c as DetailsView;
               foreach (DetailsViewRow row in view.Rows)
               {
                   ChangeColor(row.Controls);
               }
           }
           else
           {
               if (c is WebControl) ((WebControl)c).ForeColor =
System.Drawing.Color.DeepPink;
           }

       }
   }

[/code]

Thanks
Khafancoder - 13 Jul 2007 15:14 GMT

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.