So I am using asp.net to make a site, and I came across a bit of a problem. I need to edit the html from an .aspx.cs file, and while this normally isn’t a problem, the html file is located in a templates folder elsewhere in the project. I have tried using javascript, but I kept getting errors saying “cannot setAttribute/change innerHTML of type null.
Would it be better to continue trying to fix this with javascript, or does asp.net have something for this?
ALSO NOTE: the html is in an html file, not a .aspx file, so asp.net controls (such as runat=”server”) don’t work.
EDIT: What I am trying to do is hide a div that holds a navigation bar for admins if the current user is not an admin.
For javascript fixes, I have tried Page.RegisterStartUpScript and Response.Write (called from the .aspx.cs file), but both give me the error described above. I can’t (as far as I know) have a javascript file just hide the div without somehow being called or originated by the c#, as I need to find out whether or not they are an admin
What you need to do is convert the HTML document to an .aspx file and include it (Ref. http://www.mikesdotnetting.com/Article/144/Classic-ASP-Include-Files-in-ASP.NET) in the other documents where it is to be used. Then, you can reference the control in your code behind, using whatever methods are available to you for determining whether or not a user is logged in. For example:
Does that make sense to you?