I think it is a very simple question, but I'm just stuck on it.

I'm developing custom page for my SharePoint 2010 portal, and I need to add a button (or other elements) to my .aspx page:

<input type="button" id="btnID" onclick="window.location.href='/CustomPage.aspx'" value="GO!" />

I've tried to do it from codebehind:

System.Web.UI.WebControls.Button button = new System.Web.UI.WebControls.Button();
button.OnClientClick = "window.location.href='/CustomPage.aspx'";
button.ID = "btnID";
button.Text = "GO!";

However, I get this on the page:

<input type="submit" name="ctl00$PlaceHolderMain$UIVersionedContent9$btnID" value="GO!" onclick="window.location.href='/CustomPage.aspx';WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$PlaceHolderMain$UIVersionedContent9$btnID&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="ctl00_PlaceHolderMain_UIVersionedContent9_btnID" />

I'm not sure with the class, but maybe something else is wrong...

How can I add simple HTML (not ASP.NET) button to the page, without any additional values?

Thanks in advance!


1 Answer 1


you can do Response.Write, or you can use asp:Literal.

var ltlCnt = new LiteralControl();
string divStart = @"<div>";
ltlCnt.Text += divStart;
string divEnd = @"</div>";
ltlCnt.Text += divEnd;

  • pls vote the answer if that helped you :) Commented Mar 31, 2014 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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