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 got a question, How to add popap window to Sharepoint by the code. I tried many thinks, but they could be block by web browsers. I must find that want unblock by web browsers.

share|improve this question
What version of SharePoint? – Dave Wise Oct 24 '12 at 20:18
up vote 3 down vote accepted


This is a simplest form of SharePoint 2010 Modal Dialog, using SP.Dialog class!

function test() { 
            url: "/Lists/Announcements/NewForm.aspx", 
            title: "Add item", 
            allowMaximize: true, 
            showClose: true, 
            width: 800, 
            height: 600, 
           dialogReturnValueCallback: silentCallback 

   function silentCallback(dialogResult, returnValue) { 

   function refreshCallback(dialogResult, returnValue) { 

This is same dialog which opens when you add new item to a list, or edit any item! You can provide any url in SP Dialog Options!

More reading here


Try this:

LiteralControl controlLit = new LiteralControl();
controlLit.Text = "<a onclick='javascript:test();' href='#'>click here</a>";
share|improve this answer
It is Javascript, you don't have this option in .cs file.. You can write this in a Visual Web Part or a Content Editor Web Part, and call test() function on a button click or anywhere! – Arsalan Adam Khatri Oct 24 '12 at 21:04
you can inject the <script> in Content Editor Web Part, and then call the function by making <a onclick="javascript:test();" href="#">click here to open popup<\a> – Arsalan Adam Khatri Oct 24 '12 at 21:17
Yes, here you can add a new Literal Control and set popup as mentioned above! – Arsalan Adam Khatri Oct 24 '12 at 21:21
updated the answer for you! – Arsalan Adam Khatri Oct 24 '12 at 21:33
Post another question for this :D, I will give the answer there! – Arsalan Adam Khatri Oct 24 '12 at 22:01

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.