小编Roo*_*ney的帖子

如何在保存打印页面的同时为文件创建自定义文件名?

这里我通过window.print()事件打印一个页面,在打印之前我需要保存这个页面,我需要在这个事件中硬核文件名.

   <a href="_javascript:window.print()">
    <img class="noPrint" src="Images/Print_icon.png" border="0"></a>
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?

javascript asp.net

7
推荐指数
3
解决办法
1万
查看次数

如何在将数据集导出为ex​​cel时使标题字体变为粗体?

在这里,我将数据集中的数据表导出到excel.如何使数据表的标题字体看起来是粗体.这是我的代码

HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + fileName + "");
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWriter);
DataGrid dataExportExcel = new DataGrid();
foreach (DataTable table in dtInputParameters.Tables)
{
   dataExportExcel.DataSource =  table;
   dataExportExcel.DataBind();
   dataExportExcel.RenderControl(htmlWrite);
   htmlWrite.WriteLine("<br/>");
   // htmlWrite.AddStyleAttribute(System.Web.UI.HtmlTextWriterStyle.FontWeight, "bold");
}
StringBuilder sbResponseString = new StringBuilder();
sbResponseString.Append("<html xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns=\"http://www.w3.org/TR/REC-html40\"> <head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=windows-1252\"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>" + worksheetName + "</x:Name><x:WorksheetOptions><x:Panes></x:Panes></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head> <body>");
sbResponseString.Append(stringWriter + "<table width='800' height='100' align='center' style='text-align:center'");
sbResponseString.Append("</table></body></html>");
HttpContext.Current.Response.Write(sbResponseString.ToString());
HttpContext.Current.Response.End();
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?

c# asp.net export-to-excel htmlwriter

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

如何在HttpWebRequest POST中将对象作为参数传递?

这里我从我的Web应用程序调用Restful WCF服务,我不知道如何将对象作为参数传递给这个.这是我的客户端代码:

protected void Button1_Click(object sender, EventArgs e)
{
    UserInputParameters stdObj = new UserInputParameters
    {
        AssociateRefId = "323",
        CpecialLoginId = "a@gmail.com",
        PartnerId = "aaaa",
        FirstName = "aaaa",
        LastName = "bbbb",
        Comments = "dsada",
        CreatedDate = "2013-02-25 15:25:47.077",
        Token = "asdadsadasd"
    };

    string url = "http://localhost:13384/LinkService.svc/TokenInsertion";

    try
    {
        ASCIIEncoding encoding = new ASCIIEncoding();
        System.Net.WebRequest webReq = System.Net.WebRequest.Create(url);
        webReq.Method = "POST";
        webReq.ContentType = "application/json; charset=utf-8";
        DataContractJsonSerializer ser = new DataContractJsonSerializer(stdObj.GetType());
        StreamWriter writer = new StreamWriter(webReq.GetRequestStream());
        writer.Close();
        webReq.Headers.Add("URL", "http://localhost:13381/IntegrationCheck/Default.aspx");
        System.Net.WebResponse webResp = webReq.GetResponse(); …
Run Code Online (Sandbox Code Playgroud)

c# asp.net rest httpwebrequest

5
推荐指数
1
解决办法
3万
查看次数

如何在<img> src标记中连接两个字符串?

在这里,我想在<img>标签内连接两个字符串.这该怎么做??

<img src=" "/partners" + @item.AdPath" alt="" id="adimg" title="@item.AdName"  width:"50px" height="50px"/>
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?

html c# razor asp.net-mvc-4

5
推荐指数
1
解决办法
2万
查看次数

SCRIPT5007:无法获取未定义或空引用的属性"设置"

CREATE  FUNCTION [dbo].[PMURP_Func_ParseArray] (@Array VARCHAR(1000),@separator CHAR(1))
RETURNS @T Table (ExtractWords varchar(50))
AS 
BEGIN
--DECLARE @T Table (col1 varchar(50))
-- @Array is the array we wish to parse
-- @Separator is the separator charactor such as a comma
DECLARE @separator_position INT -- This is used to locate each separator character
DECLARE @array_value VARCHAR(1000) -- this holds each array value as it is returned
-- For my loop to work I need an extra separator at the end. I always look to …
Run Code Online (Sandbox Code Playgroud)

jquery jquery-validate internet-explorer-9

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

如何编写可重用的linq查询

在这里我需要重用linq查询,在两个地方稍微改变,比如if和else condition.如何编写可重用的linq查询

if(some condition){
   comms = (from s in config.PromoRegistration.Communications.Cast<CommunicationGroupConfiguration>()
            from c in s.Communications.Cast<CommunicationConfiguration>()
            where s.CurrentBrand == true
            select c).ToList().FirstOrDefault();
}
else{
    comms = (from s in config.Subscriptions.Cast<CommunicationGroupConfiguration>()
             from c in s.Communications.Cast<CommunicationConfiguration>()
             where s.CurrentBrand == true
             select c).ToList().FirstOrDefault();
}
Run Code Online (Sandbox Code Playgroud)

这里

config.PromoRegistration.Communications.Cast<CommunicationGroupConfiguration>() 
Run Code Online (Sandbox Code Playgroud)

只有这一部分在这两个查询中发生了变化.如何有效地编写这个查询.任何建议.

.net c# linq linq-to-entities

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

如何使用ExecuteScalar检索多个列?

我正在使用以下列ExecuteScalar:

 cmd.commandtext = "select rodeuser from customer_db_map";
    string rodecustomer = cmd.executescalar;
Run Code Online (Sandbox Code Playgroud)

但我需要获得多个专栏,例如:

 cmd.commandtext = "select rodeuser,username,password from customer_db_map";
Run Code Online (Sandbox Code Playgroud)

我需要字符串中的每一列:

 string rodecustomer = cmd.ExecuteScalar();
 string username= cmd.ExecuteScalar();
 string password = cmd.ExecuteScalar();
Run Code Online (Sandbox Code Playgroud)

但这是不可能的.这是如何实现的?

c#

3
推荐指数
2
解决办法
1万
查看次数

如何从模型列表中获取最后一个值而不在MVC中循环它?

在这里,我需要从视图中的模型列表中获取最后一个值而不循环它.这是我的控制器代码

public IList<ProductDetailModel> GetWPDetails()
            {
                ProductDetailModel Viewmodel;
                string funname = "GetCSpecialWPDetails";
                List<ProductDetailModel> getWPDetails = new List<ProductDetailModel>();
                getWPDetails = objrest.EcommerceWPDetails(funname);
                List<ProductDetailModel> WPDetails = new List<ProductDetailModel>();

                foreach (var item in getWPDetails)
                {
                    Viewmodel = new ProductDetailModel();
                    Viewmodel.Productid = item.Productid;
                    Viewmodel.ProductName = item.ProductName;
                    Viewmodel.CategoryID = item.CategoryID;
                    Viewmodel.ProductRate = item.ProductRate;
                    Viewmodel.DiscountRate = item.DiscountRate;
                    Viewmodel.imageurl1 = item.imageurl1;
                    WPDetails.Add(Viewmodel);
                }
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString);
                SqlCommand cmd = new SqlCommand("SELECT ThemeColor,LayoutDesign FROM dbo.Cpecial_Partner_Design WHERE [PartnerID]='" + Partid + "'", con);
                con.Open();

                using (SqlDataReader myReader = cmd.ExecuteReader()) …
Run Code Online (Sandbox Code Playgroud)

c# linq asp.net-mvc-4

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

如何检查是否已使用javascript单击按钮?

在这里,我需要使用javascript检查按钮单击ie)如果单击按钮A我将调用javascript函数,如果单击按钮B,我将调用另一个javascript函数.

if(document.getElementById('imgBTNExportPPT').clicked == true)
{
   ShowDialogExportPPTPOPUP();
}
else if(document.getElementById('btnShowModal').clicked == true)
{
   ShowDialogPrintPOPUP();
}
Run Code Online (Sandbox Code Playgroud)

      <asp:ImageButton ID="imgBTNExportPPT" runat="server" Width="15" Height="15" border="0"
                                                            OnClick="imgBTNExportPPT_Click" ImageUrl="~/Images/PPT_icon.png" />
  <asp:ImageButton ID="btnShowModal" runat="server" Width="15" Height="15" border="0"
                                                         ImageUrl="~/Images/Print_icon.png" onclick="btnShowModal_Click"  />
Run Code Online (Sandbox Code Playgroud)

有可能吗??任何建议?

javascript c# asp.net

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