0

in HTML:

<script type="text/javascript">
function removeIndustry(item)
    {
        confirm(item);
    }
</script>

in C#:

protected void Page_Load(object sender, EventArgs e)
{
    Label1.Text = "<a href='javascript:removeIndustry('IndustryNameHere')'><i class='icon-remove'></i></a>Click";
}

The code is not working if I put any strings like 'IndustryNameHere' in that function. Without any values, it is working fine. Anyone please help me fix this error. Thanks a lot.

2
  • It could be because of the use of ' single-quote for the parameter. Seems to me that these quotes are in conflict with each other. Can you share your resulting HTML of what you have currently? i.e. with this IndustryNameHere string in it. Commented Aug 16, 2015 at 11:37
  • Try using &quot; instead of single-quote for the parameters to be wrapped around with i.e. it should look like this: "<a href='javascript:removeIndustry(&quot;IndustryNameHere&quot;)'><i class='icon-remove'></i></a>Click";. Commented Aug 16, 2015 at 11:39

1 Answer 1

2

Try to escape quotes with \:

protected void Page_Load(object sender, EventArgs e)
{
    Label1.Text = "<a href=\"javascript:removeIndustry('IndustryNameHere')\"><i class='icon-remove'></i></a>Click";
}
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.