小编Tom*_*len的帖子

函数返回两个值

我想问一下这个功能的效果如何,以及是否有任何可以使用它的情况.谢谢你的回答.

function sum_and_dif(a, b) {
    var c = a + b;
    var d = a - b;
    return c +" " + d;
}

var result = sum_and_dif (200, 10);

document.write(result +"</br>");

var where_is_a = result.indexOf(" ");// Here i detected where is the empty space
var c_number = parseInt(result.substring(0, where_is_a));
var d_number = parseInt(result.substring(where_is_a +1,result.length));

document.write(c_number +"</br>");
document.write(d_number +"</br>");
Run Code Online (Sandbox Code Playgroud)

javascript

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

Jquery foreach循环

$("#<%=ApprovalSelectPanel.ClientID %> input:checkbox:checked").each(function(){

    alert(this.val);

});
Run Code Online (Sandbox Code Playgroud)

这不会在每个复选框上返回value属性,而是返回 undefined

javascript foreach jquery loops

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

c#带条件语句|

鉴于:

bool isBold = true;
bool isItalic = true;
bool isStrikeout = false;
bool isUnderline = true;

System.Drawing.Font MyFont = new System.Drawing.Font(
    thisTempLabel.LabelFont,
    ((float)thisTempLabel.fontSize),
    FontStyle.Bold | FontStyle.Italic | FontStyle.Strikeout | FontStyle.Underline,
    GraphicsUnit.Pixel
);
Run Code Online (Sandbox Code Playgroud)

我如何应用布尔值来确定我应该使用哪些字体样式?上面的代码使它们全部适用,所以它是粗体,斜体,删除线和下划线,但我想基于bools进行过滤.

c# fonts if-statement operators

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

c#Linq - 这是一个删除记录的好设计吗?

/// <summary>
/// Deletes a template data record
/// </summary>
/// <param name="RecordID">ID of the record</param>
public static void DeleteDataRecord(int RecordID)
{
    ArtworkingDataContext dc = new ArtworkingDataContext();

    // Delete associated datalabels
    var q = dc.tblArtworkDataLabels.Where(c => c.dataID == RecordID);
    dc.tblArtworkDataLabels.DeleteAllOnSubmit(q);
    dc.SubmitChanges();

    // Delete the data record        
    var qq = dc.tblArtworkDatas.Where(c => c.ID == RecordID);
    dc.tblArtworkDatas.DeleteAllOnSubmit(qq);
    dc.SubmitChanges();
}
Run Code Online (Sandbox Code Playgroud)

我需要两次调用deleteallonsubmit(),还是只需要一次?

c# linq

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

无法将控件添加到usercontrol

这有效:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Comments.ascx.cs" Inherits="Controls_Comments" %>

Add comment
Run Code Online (Sandbox Code Playgroud)

但是这个:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Comments.ascx.cs" Inherits="Controls_Comments" %>

Add comment
<asp:Button runat="server" ID="lol" />
Run Code Online (Sandbox Code Playgroud)

抛出我以前从未见过的错误:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1502: The best overloaded method match for 'System.Web.UI.Control.ApplyStyleSheetSkin(System.Web.UI.Page)' has some invalid arguments

Source Error:


Line 190:            #line hidden
Line 191:            this.lol = …
Run Code Online (Sandbox Code Playgroud)

c# asp.net user-controls

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

Jquery获取HTML

我有代码:

// Get message
var PostTxt = $('#cid367', '.comment-txt').html();
PostTxt = $.trim(PostTxt);
Run Code Online (Sandbox Code Playgroud)

它试图从这个结构中检索注释:

<div id="cid367" class="comment-wrapper">  
    <div class="comment-head ch-highlight">        
        <div class="comment-date">    
            <abbr class="timeago" title="2011-04-25T15:15:52.4070000">25 April 2011 at 15:15:52</abbr>    
        </div>    
        <div class="comment-author">    
            Written by <a id="A1" title="Visit this game makers profile" href="../../../users/Tom">Tom</a>    
        </div>  
    </div>     
    <table class="comment-body" width="100%">    
        <tr>    
            <td width="100" valign="top" align="center">    
                <a id="A2" title="Tom makes games with Construct 2" href="../../../users/Tom"><img id="Img1" title="Tom&#39;s Gravatar" class="comment-avatar" src="http://www.gravatar.com/avatar/5271d3283db957ef3a86761ed15c1696?r=pg&amp;s=80" /></a>
            </td>    
            <td valign="top">    
                <div id="ModBox" class="comment-modbox" style="margin-left:-105px;">  
                    <a id="CommentReportPost" title="Report this post" class="s comment-report"></a> …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

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

帮助Regexp

鉴于测试字符串:

<div class="comment-quoter">Comment by <strong>Tom</strong>
Run Code Online (Sandbox Code Playgroud)

我想把它改成

[quote=Tom]
Run Code Online (Sandbox Code Playgroud)

我已经达到了这个但它没有匹配:

PostTxt = PostTxt.replace(new RegExp("<div class=\"comment-quoter\">Comment by <strong>{(.+),}</strong>", "g"), '[quote=$1]')
Run Code Online (Sandbox Code Playgroud)

javascript regex

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

c#更优雅的方式将数组分配给列表?

我有这个:

// Load changelog types
ChangeLogType[] Types = ChangeLogFunctions.GetAllChangelogTypes();
foreach(ChangeLogType Rec in Types){
    ListItem N = new ListItem();
    N.Text = Rec.Type;
    N.Value = Rec.ID.ToString();
    LstChangeLogType.Items.Add(N);
}
Run Code Online (Sandbox Code Playgroud)

它调用一个返回ChangeLogTypes数组的函数,然后将每个函数添加到列表控件中.有更优雅的方式吗?我觉得我每次做这个或类似的东西都会重复代码.

c# asp.net listcontrol

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

Linq方法返回随机记录集

我有这个功能:

/// <summary>
/// Returns an array of random articles, ID and titles only
/// </summary>
/// <param name="SectionID">Section ID to return</param>
/// <param name="Count">Number of articles to return</param>
/// <returns></returns>
public ArticleOverview[] RandomArticles(int SectionID, int Count)
{
    ArticleOverview[] ReturnLinks;

    // Pick a random tutorial and redirect to it
    using (MainContext db = new MainContext())
    {
        // Select rows
        var q = (from c in db.tblArticles where c.IsDeleted == false && c.SectionID == SectionID select new { c.ID, c.Title }); …
Run Code Online (Sandbox Code Playgroud)

c# linq random methods sql-server-2008

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

ASP.net web.config没有捕获所有404的

在我的web.config中,我有:

    <customErrors mode="On" defaultRedirect="~/Error.aspx" redirectMode="ResponseRewrite">
        <error statusCode="500" redirect="~/Error.aspx" />
        <error statusCode="404" redirect="~/404.aspx" />
    </customErrors>
Run Code Online (Sandbox Code Playgroud)

然而,使用这些URL,只有定义了文件扩展名的第二个工作,另一个返回蓝色屏幕404"应用程序中的服务器错误".

http://127.0.0.1/scirranew/invalidpath

http://127.0.0.1/scirranew/invalidpath.aspx
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?我在ASP.net 4,IIS 7.5上.

asp.net web-config custom-error-pages http-status-code-404

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