Alternate option for RegisterClientScriptBlock, Is going for 100% javascript good option?

225 Views Asked by At

i have following situation

try
{
    // do something
}
catch(Exception e)
{
    RegisterClientScriptBlock();
    // **can i do this using Jquery replacing RegisterClientScriptBlock**
}

i have aspx pages which are heavily using RegisterClientScriptBlock for emitting javascript code is it a better way to write a javascript library and put directly into the page in place of RegisterClientScriptBlock

My current application calls the business logic and decides which javascript to call by using RegisterClientScriptBlock

example

c# code

RegisterStartupScript("", "<script>ShowConvertedAlertMessage('Docs:" &   Docs.Home.GetAlertMessage("OB19") & "');</script>")

Docs is the object which i am getting from the DLL

is there anyother way i can do this using jQuery

1

There are 1 best solutions below

0
On

You can inject Jquery code the same way, in place of plain Javascript. Jquery at the end is Javascript code. If you are executing RegisterStartupScript when some condition is met or when an event fires in server side. I think ResigterStartUpScript is fine.