SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have added a literal control in my visual web part VisualWebPart1.ascx file as follows:

<asp:Literal id="slider"></asp:Literal>

I am trying to access it in VisualWebPart1.ascx.cs file as follows but it is not working:

protected void Page_load(object sender, EventArgs e)
      slider.Text = "Testing";
share|improve this question

Fixed it by adding runat="server" attribute in literal. Silly mistake!

share|improve this answer
lol yes it is ;), without the runat=server it wouldnt be available within the .cs as thats run at the server :) – ali Sharepoint Apr 8 '13 at 13:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.