ASP.NET and jQuery - a call from codebehind

This is a problem that I tried to solve so before, but came up with. I mainly use ModalPopupExtenders (from AJAX.NET) to display panels with multiple content (text, controls, etc.). And I call it from codebehind. And it works well.

But now I want to replace ModalPopup with some jQuery dialog box. The problem is calling it from code. As far as I know, I need to register jQuery libraries in the RegisterStartup event, but I tried it and called jQuery from codebehind, but without sucess.

Can someone help me? I really want to replace ModalPopup, they bring me a lot of trouble.

Thanks in advance.


protected void Page_Load(object sender, EventArgs e)
{
    ScriptManager.RegisterStartupScript(this, GetType(), "registerDialog",
        "$(function() { $('#dialog').dialog({autoOpen:false, show:'blind'}); });", true);
}

protected void Button1_Click(object sender, EventArgs e)
{
    ScriptManager.RegisterStartupScript(this, GetType(), "openDialog",
        "$('#dialog').dialog('open');", true);
}

Is it correct? I must first register it in order to stay hidden. Thanks

+3
2

ScriptManager, RegisterStartupScript(), :

ScriptManager.RegisterStartupScript(this, GetType(), "modalscript",
    "$(function() { $('#dialog').dialog(); });", true);

ScriptManager/UpdatePanels, ClientScriptManager.

, document.ready ( IE ), ( , id="dialog") DOM .

+4

jQuery , javascript, ( PostBack).

jQuery.

+1

Source: https://habr.com/ru/post/1765255/


All Articles