小编rup*_*r18的帖子

使用css打印div内容

我正在研究一个项目,我想打印div内容.我正在使用的代码满足了我的要求,但我得到了简单的输出而没有应用Css,也没有得到图像.请帮助我.我附上我想要的代码和输出和输出.

码:

function PrintElem(elem) {
    Popup($(elem).html());
}

function Popup(data) {
    var mywindow = window.open('', 'new div', 'height=400,width=600');
    mywindow.document.write('<html><head><title></title>');
    mywindow.document.write('<link rel="stylesheet" href="css/midday_receipt.css" type="text/css" />');
    mywindow.document.write('</head><body >');
    mywindow.document.write(data);
    mywindow.document.write('</body></html>');

    mywindow.print();
    mywindow.close();

    return true;
}
Run Code Online (Sandbox Code Playgroud)

我在点击打印按钮之前得到的输出: 在此输入图像描述

单击打印按钮我得到的输出: 在此输入图像描述

javascript css asp.net

16
推荐指数
4
解决办法
6万
查看次数

通过ajax调用传递给mvc控制器时,在列表中获取空值

我将我的列表传递给mvc控制器,但我在控制器中获取空值.但是当我在客户端显示警报时,我的列表中有值.

ajax电话

$("#addTiles").click(function() {
    userTiles = JSON.stringify({
        'userTiles': userTiles
    });
    alert("Entered function.");
    alert(userTiles[0].TileID);
    var url = '@Url.Action("AddTiles")';
    $.ajax({
        type: "GET",
        url: url,
        data: userTiles,
        success: function(d) {
            if (d.indexOf('"IsSessionExpired":true') != -1) {
                location.reload();
            } else {
                onAddTilesSuccessful(d);
            }
        },
        error: function() {
            errorInOperation();
        },
        contentType: "application/html; charset=utf-8",
        dataType: 'html'
    });
});

function onAddTilesSuccessful(e) {
    $("#tilesSubmissionMsg").append(e);
}

function errorInOperation(d) {
    $("#tilesSubmissionMsg").append("Something went wrong");
}
Run Code Online (Sandbox Code Playgroud)

mvc控制器

  public ActionResult AddTiles(List<UserTilesVM> userTiles)
    {
        return View();
    }
Run Code Online (Sandbox Code Playgroud)

列表模型

public class UserTilesVM
{
    public int TileID …
Run Code Online (Sandbox Code Playgroud)

javascript ajax asp.net-mvc asp.net-mvc-4

6
推荐指数
2
解决办法
4882
查看次数

由于其保护级别,无法访问链接按钮单击事件

我正在做一个项目。我正在动态创建一个asp表,并在表单元格中根据条件添加了link按钮。但是在添加Click事件到link按钮时,它给出了一条错误消息-

System.Web.UI.WebControls.LinkButton.OnClick(System.EventArgs)' is inaccessible due to its protection level
Run Code Online (Sandbox Code Playgroud)

以下是我制作桌子的代码

protected void Page_Load(object sender, EventArgs e)
{       
    if(!IsPostBack)
    {         
      setmonthname();
    }
     makeCalendar();
}
public void makeCalendar()
{
    tblcalendar.Rows.Clear();
    //for current month
    DateTime startingdate = StartDateOfMonth(DateTime.Now.AddMonths(monthclickedno));
    DateTime enddate = EndDateOfMonth(DateTime.Now.AddMonths(monthclickedno));
    string startingday = startingdate.DayOfWeek.ToString();
    int startingdayno = Convert.ToInt32(startingdate.DayOfWeek);
    string endday = enddate.DayOfWeek.ToString();//like saturday is 6,stating is from monday with 1 and ending si sunday with 7
    int enddayno = Convert.ToInt32(enddate.DayOfWeek);
    //for prevoius month
    DateTime enddateprevious = (EndDateOfMonth(DateTime.Now.AddMonths(monthclickedno)));
    //for next month
    DateTime …
Run Code Online (Sandbox Code Playgroud)

c# asp.net asplinkbutton

1
推荐指数
1
解决办法
1934
查看次数