开发者

can you use jqmodal ajax with web forms

开发者 https://www.devze.com 2023-04-08 17:43 出处:网络
is there a way to use jqmodal\'s ajax property with asp.net webforms? <script type=\"text/javascript\">

is there a way to use jqmodal's ajax property with asp.net webforms?

<script type="text/javascript">
    $(document).ready(function() {
        $('#Button1').click(function() {
        $('#modalContent').jqm({
            ajax: "~/ShelterCreateFo开发者_StackOverflow社区rm.ascx"
        });
        $('#modalContent').jqmShow(this);
        return false;
    });
});
</script>


jqModal is server side technology agnostic meaning that it can be used with absolutely any language on the server including WebForms in condition that it points to a server side url which returns the partial html:

<script type="text/javascript">
    $(function() {
        $('#Button1').click(function() {
            $('#modalContent').jqm({
                ajax: '<%= ResolveUrl("~/Foo.ashx") %>'
            });
            $('#modalContent').jqmShow(this);
            return false;
        });
    });
</script>

And the server side url that returns this partial (Foo.ashx) might be a generic handler as shown in this answer:

public class FooHandler : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/html";
        context.Response.Write(RenderPartialToString("ShelterCreateForm.ascx"));
    }

    private string RenderPartialToString(string controlName)
    {
        var page = new Page();
        var control = page.LoadControl(controlName);
        page.Controls.Add(control);

        using (var writer = new StringWriter())
        {
            HttpContext.Current.Server.Execute(page, writer, false);
            return writer.ToString();
        }
    }

    public bool IsReusable
    {
        get { return false; }
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消