Codebehind and inline on the same page in ASP.NET?

In ASP.NET, is it possible to use both the code behind and inline in the same page? I want to add inline code related to the UI of the page, the reason for creating it is to make it easier to modify as it outputs some HTML, so I don't want to add it to the code behind, is this possible in ASP.NET?

Edit: Sorry, obviously my question was not very clear, I meant using a script block with runat = "server", this is what I meant by inline code.

thank

+1


source to share


2 answers


Yes, you can use inline code like in classic asp. You can use 'this' or 'me' to access code behind fields, methods, etc.



+4


source


Yes it will work, make sure the code behind the class is declared as a partial class, which is the default these days. Don't assume this will work in 1 or 1.1



+1


source







All Articles