Reputation: 105
Please help me solve this challenge:( I have below code:
Label lblVideoAssessment = new Label();
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 above code by a dialogue box instead of opening a new page "Ässessment.aspx". I have tried like this:
lblVideoAssessment.Text = "<a cssclass='IconDisplayCss' width='300px' height='300px' onclick='javascript:OpenDialog('../SitePages/Assessment.aspx?cat='+cat+);return false;'><img border='none' src='~/_layouts/images/Assessment.png'></a>";
However it doesnot work.
I think the issue is with the ''
(Quotation which i have placed ) or do i need to use Page.ClientScript.RegisterStartupScript
if yes...how and where do i place it?
Please help as i have been struggling for fort night.
I had also got suggestion to use Literal Control.I have tried that as well and it does not work.
Upvotes: 0
Views: 3175
Reputation: 911
var strScript = "<script language=\"JavaScript\" type=\"text/javascript\">";
strScript += "alert(\"hello\")";
strScript += "</script>";
Page.ClientScript.RegisterClientScriptBlock(GetType(), "onload", strScript, false);
Good Luck!
Edit:
var script = "<script language=\"JavaScript\" type=\"text/javascript\">$('#tag').click(function () {})</script>"; Page.ClientScript.RegisterClientScriptBlock(GetType(), "ready", script , false);
Finally:
var script = "<script language=\"JavaScript\" type=\"text/javascript\">$(\".IconDisplayCss\").click(function () {OpenDialog('../SitePages/Assessment.aspx?cat='" + cat + "); });</script>" Page.ClientScript.RegisterClientScriptBlock(GetType(), "ready", script , false);
Upvotes: 1