0

I have this code in my .ascx.cs file which calls to new page on href.

lblVideoAssessment.Text = "<a href='../SitePages/Assessment.aspx?cat=" + cat + "' height='300px' width='300px' Target='_blank' cssClass='IconDisplayCss'><img src='~/_layouts/images/Assessment.png' border='none'/></a><br/>" + cat;

I want to replace this code to javascript popup page to change look and feel.i want to make page as popup for which i have written a javascript method in .ascx file which is given below:

<script type="text/javascript">
    function OpenDialog(URL) {
        var NewPopUp = SP.UI.$create_DialogOptions();
        NewPopUp.url = URL;
        NewPopUp.width = 700;
        NewPopUp.height = 350;
        SP.UI.ModalDialog.showModalDialog(NewPopUp);
    }
 </script>

I have called the javascript in code behind like this and it does not work:

lblVideoAssessment.Text = "<a OnClick='javascript:OpenDialog('../SitePages/Quiz.aspx')' height='300px' width='300px' Target='_blank' cssClass='IconDisplayCss'><img src='~/_layouts/images/Assessment.png' border='none'/></a><br/>" + cat;

Please advice what to do. The same works fine with sharepoint designer. Please help how to pass the javascript method on OnClick.

1 Answer 1

1

It sounds like you simply want the html that you are assigning to lblVideoAssessment.Text to be placed in the page, exactly as it is. For that, an <asp:Label ... /> is not the right type of control to use.

Instead, you want an <asp:Literal ... />. Then the assignment will be basically the same as what you currently have:

litVideoAssessment.Text = "<a OnClick='javascript:OpenDialog('../SitePages/Quiz.aspx')' height='300px' width='300px' Target='_blank' cssClass='IconDisplayCss'><img src='~/_layouts/images/Assessment.png' border='none'/></a><br/>" + cat;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.