Pregunta

I have a method which return type is string. From the method i want to call a javascript method which is inside .aspx page.But the javascript method is not getting called. below is my code

private string test()
{
   if(somecondition)
   {
       ScriptManager.RegisterStartupScript(Page, GetType(), "HideSlider1", "HideSlider();", true);
   }
   return stringvalue;
}
¿Fue útil?

Solución

Use ClientScript class instead of ScriptManager

private string test()
{
   if(somecondition)
   {
       ClientScript.RegisterStartupScript(Page.GetType(), "HideSlider1", "HideSlider();", true);
   }
   return stringvalue;
}

Otros consejos

Try this.

private string test()
{
    if(somecondition)
    {
         ScriptManager.RegisterClientScriptBlock(Page, GetType(), "HideSlider1", "<script type='text/javascript'>HideSlider();</script>", true);
    }
    return stringvalue;
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top