j4rey89 j4rey89 - 1 year ago 87
ASP.NET (C#) Question

How to check if Literal exists in server side?

I have 2 aspx pages that uses the same aspx.cs file using CodeFile

I have on one aspx page but not on the other aspx page.

On runtime I want to check if the Literal exist then set the value if it doesn't do nothing.

Answer Source

Did you try using FindControl method?

Literal l = FindControl("control id");

if(l != null)
    //do your processing