I’m trying to remove a <br />
from my page.aspx file dynamically according to information received from a previous page. I’ve tried giving the br an id and attempting to remove it like this:
in page.aspx:
<br id="Break" />
in page.aspx.cs:
Page.Form.Controls.Remove(Break);
This doesn’t work and it tells me that the name ‘Break’ does not exist in the current context.
I’m using Page.Form.Controls.Remove in other lines of my code and it’s working perfectly fine but when I try and remove a <br />
it always gives me an error.
Is there another way to dynamically remove <br />
from my page.aspx that I could use?
2
Answers
You can try to use Replace function
Yes, if you do
<br runat="server" id="break" />
. but setthis.break.Visible = false;
instead ofRemove
.