Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a working solution according to below, but I want a dynamic link which is created in Createchildcontrols and included as an arguement in the function newitem but I get an JavaScript error on the page

my dynamic link:

string url = site.ServerRelativeUrl + "/_layouts/Upload.aspx?List={" + sourceList.ID + "}&RootFolder=";

I have tried

link.NavigateUrl = string.Format("javascript: newitem(" + url + ")");


sb.Append("function newitem(String URL) {");
sb.Append("options.url = URL;");  

working solution:

protected override void CreateChildControls()
{
link.NavigateUrl = string.Format("javascript: newitem()");
}


    protected override void OnPreRender(EventArgs e)
    {

        String csname1 = "PopupScript9";

        StringBuilder sb = new StringBuilder();
        sb.Append("function newitem() {");
        sb.Append("var options = SP.UI.$create_DialogOptions();");

        sb.Append("options.url = '<some aspx site>';");  
        sb.Append("SP.UI.ModalDialog.showModalDialog(options);");  
        sb.Append("}");

        Type cstype = this.GetType();


        ClientScriptManager cs = Page.ClientScript;

        if (!cs.IsStartupScriptRegistered(cstype, csname1))
        {
            cs.RegisterStartupScript(cstype, csname1, sb.ToString(), true);
        }
   }
share|improve this question
1  
If you have a working solution, what is the question? –  Steve B Oct 10 '12 at 9:46
    
exactly, what is the question? is your "working solution" is not working or you need a better way? –  Diptarag Oct 10 '12 at 12:42

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.