开发者

can you use jqmodal ajax with web forms

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜