Skip to content

Call javascript function in asp.net,c#

suganya pv

Asked Mar 27, 2009, 1:35 AM EDT2 answers
Share
LinkedInX
Hi,
I have sample javascript function it have 2 parameter values. so how to access this script fuction in asp.net,c#.

Having javascript is:

<script language="javascript" type="text/javascript">
function splitLine(st,n)
{
var b = '';
var s = st;
while (s.length > n)
{
var c = s.substring(0,n);
var d = c.lastIndexOf(' ');
var e =c.lastIndexOf('\n');
if (e != -1) d = e;
if (d == -1) d = n;
b += c.substring(0,d) + '\n';
s = s.substring(d+1);
}
return b+s;
}
</script>

So how to use this script inside asp.net,c# and also how to pass values to this parameter.




Thanks.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Bechir Bejaoui
    0
    Page.RegisterStartupScript("myScript", "<script language=JavaScript>SplitLine('" + arg1 +"' +","+ '"+ agr2 +"');</script>");
    0
  • Niradhip Chakraborty
    0
     
    Or You can try this also:

    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "SplitLine('" + arg1 +"' +","+ '"+ agr2 +"');", true);
    0