Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Dev Studio removes custom code when I change a page in the designer

  Asked By: Cesar    Date: Mar 09    Category: Asp.net    Views: 781
  

I've run into a couple very irritating problems when using the web
page designer within MS Dev Studio:

1) If I have added any custom attributes to an element in the ASPX
file via the HTML tab (e.g. adding runat="server" to the title
element, those changes are lost if I make any changes to the page
via the Designer tab.

2) If I have added any custom attributes to an element in the code-
behind file (e.g. TextBox1.Attributes.Add("OnChange", "DoSomethings
();" -- to enable client-side calculations), those changes are also
lost if I do anything in the designer. It appears that I have to add
this code to the InitializeComponent method, which is constantly
overwritten by the designer. If I put the statement in the Page_Load
method, it doesn't work.

I'm love 99% of the Dev Studio features, but it's not acceptable to
have our code being overwritten. Does anyone know of a workaround?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Rickey Scott     Answered On: Mar 09

You can try disabling VSS's autoformat features...

Go to Tools/Options/Text Editor/"HTML/XML" -- select Format & peep the
section on "Apply automatic formatting" & uncheck the 2 options, and any
other formatting options you want disabled in that box.

This worked for me - as far as disabling the designer  from changing
attributes,etc - but it still alters my line wrapping and indentions.
Haven't figured that one out yet...

 
Answer #2    Answered By: Monique Perry     Answered On: Mar 09

You just have to keep making your extra changes in OnInit, i.e. just before or
after InitializeComponent().

Same in WindowsForms.

 




Tagged: