tags:

views:

21

answers:

1
ClientScript.RegisterStartupScript(
    this.GetType(),
    "ReturnScript", 
    "<script language='javascript'> alert('" + ErrorMsg + "');</script>");

alternate in java (JSF)

+1  A: 

Just print the JS code as-is in the JSF view. The JS runs at client machine, not at server machine. You can use <h:outputText> for this.

<h:outputText value="<script>alert('foo');</script>" escape="false" />

You can even get it as a bean property:

<h:outputText value="#{bean.script}" escape="false" />

The escape="false" is there to prevent the (default) HTML-escaping of the value.

See also:

BalusC