动态添加的用户控件不使用CSS样式

时间:2015-02-18 15:12:54

标签: jquery css asp.net webmethod

我有一个webmethod,我用它通过jQuery ajax函数在我的网页中添加了一个用户控件。这工作正常,我可以看到我的数据库中的更改,我也可以看到UI更新,但是当添加到div时,新控件应该作为手风琴呈现在UI中,但是它只是呈现它就像它一样简单没有使用CSS文件。

ASP.NET

<div runat="server" id="dvProjects" class="dvProjectAccordion dvAccordion">
</div>

的WebMethod

     [WebMethod]
        public string LoadProjectControl(UserProject addedProject)
        {
            using (Page page = new Page())
            {
                ProjectControl projectUserControl = (ProjectControl)page.LoadControl("~/UserControls/ProjectControl.ascx");
                projectUserControl.Project = addedProject;
                projectUserControl.CreateProjectControl();
                using (StringWriter writer = new StringWriter())
                {
                    page.Controls.Add(projectUserControl);
                    HttpContext.Current.Server.Execute(page, writer, false);
                    return writer.ToString();
                }
            }
        }

**jQuery**

function AddUserProject() {
    var projectDialog = $('.dvEditExhibition');
    var projectName = projectDialog.find('.txtProjectName').val();
    var projectDescription = projectDialog.find('.txtProjectDescription').val();

    var project= JSON.stringify({
        'projectId': "00000000-0000-0000-0000-000000000000",
        'projectName': projectName,
        'projectDescription': projectDescription
    });

    $.ajax({
        type: "POST",
        url: "PresentationService.asmx/AddUserProject",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: project,
        success: function(response) {
            var data = response.d;
            console.log(data);
            var dvProjects = $('.dvProjectAccordion');
            dvProjects.append(data);
            $(".dvAccordion").accordion("refresh");
        },
        error: function(response) {

        }
    });
}

0 个答案:

没有答案