我有一行php代码,如下所示:
echo "<script>$('#edit_errors').html('<h3><em>Please Correct Errors Before Proceeding</em></h3>')</script>";
Run Code Online (Sandbox Code Playgroud)
我想知道如何正确地为文本添加字体颜色.如果我这样做:
echo "<script>$('#edit_errors').html('<h3><em><font color="red">Please Correct Errors Before Proceeding</font></em></h3>')</script>";
Run Code Online (Sandbox Code Playgroud)
"red"一词是黑色文本,编译器抛出错误.
如果我在红色周围使用单引号,则文本根本不显示.
任何帮助都会很棒.谢谢
我有一个包含多个属性的对象列表.这是对象.
public class DataPoint
{
private readonly string uniqueId;
public DataPoint(string uid)
{
this.uniqueId = uid;
}
public string UniqueId
{
get
{
return this.uniqueId;
}
}
public string ScannerID { get; set; }
public DateTime ScanDate { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
现在在我的代码中,我有一个巨大的列表,数百甚至几千.
每个数据点对象属于某种类型的扫描仪,并具有扫描日期.我想删除在同一天扫描的任何数据点,除了给定机器的最后一个数据点.
我尝试使用LINQ如下,但这不起作用.我还有很多重复的数据点.
this.allData = this.allData.GroupBy(g => g.ScannerID)
.Select(s => s.OrderByDescending(o => o.ScanDate))
.First()
.ToList();`
Run Code Online (Sandbox Code Playgroud)
我需要按扫描仪ID对数据点进行分组,因为可能会在同一天但在不同的计算机上扫描数据点.如果有多个,我只需要一天的最后一个数据点.
编辑以供说明 - 最后一个数据点是指给定机器的给定扫描日期的最后扫描数据点.我希望有所帮助.因此,当按扫描仪ID进行分组时,我尝试按扫描日期进行排序,然后仅将上次扫描日期保留为多次扫描的天数.
以下是2台机器的一些测试数据:
Unique ID Scanner ID Scan Date
A1JN221169H07 49374 2003-02-21 15:12:53.000
A1JN22116BK08 49374 2003-02-21 15:14:08.000
A1JN22116DN09 49374 2003-02-21 15:15:23.000 …Run Code Online (Sandbox Code Playgroud) 当我点击页面上的示例链接按钮时,会弹出一个简单的对话框.我想要做的是将onclick jquery函数从链接更改为我表中的一个按钮.按钮当前将Web浏览器定向到新页面,但是我希望它们打开带有相应视图文件的dailog框.我正在使用CakePHP 2.x. 我研究了使用href,但我不知道该怎么做.
这是我的index.ctp文件的代码,按钮所在的位置.
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/start/jquery-ui.css" type="text/css" media="all" />
<a href="#">link</a> <!-- this is to test if the dialog box works -->
<div id="dialog"></div>
<script>
var p = '<p>test test test test test test</p>';
$('#viewButton').click(function()
{
// $(location).attr('href', 'view.ctp'); // not sure if this line of code is on the right track or not
$(p).dialog(
{
width: 400,
height: 400,
modal: true,
resizable: true,
buttons:{
OK: function(){
$(this).dialog("close");}}
});
})
</script>
<p><marquee><u>Local Clocks</u></marquee></p>
<table>
<thead><tr>
<th>Id</th>
<th>Name</th>
<th>Actions</th> …Run Code Online (Sandbox Code Playgroud) 在我的表中,我有一个列,每行都有一个复选框.我希望能够删除所有选定的项目.我找到了这个网站的代码,并根据我自己的东西进行了修改. 链接
我按照网站的复选框命名约定,如下:
<td> <?php echo $this->Form->checkbox('LocalClocks.id.['.$LocalClock['LocalClock']['id'].']', array('value' => $LocalClock['LocalClock']['id'])); ?></td>
Run Code Online (Sandbox Code Playgroud)
这是我的控制器中deleteSelected()函数的代码:
public function deleteSelected()
{
foreach($this->data['LocalClocks'] as $key => $value)
{
if($value != 0)
{
$this->LocalClock->del($value);
}
}
$this->redirect($this->referer());
}
Run Code Online (Sandbox Code Playgroud)
这是实际删除按钮的代码(以防万一需要):
<?php echo $this->Form->postLink('Delete Selected', array('action' => 'deleteSelected'), array('confirm' => 'Are you sure?')); ?>
Run Code Online (Sandbox Code Playgroud)
我认为有几件事可能是问题所在:
任何帮助都会很棒.
我正在处理一个小的XSLT文件来复制XML文件的内容并删除声明和根节点.根节点具有名称空间属性.
我目前正在使用它,除了现在命名空间属性现在被复制到直接子节点.
这是我的xslt文件到目前为止,没有什么大或复杂的:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" encoding="utf-8"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/*">
<xsl:apply-templates select="node()" />
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
我的输入文件是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<Report_Data xmlns="examplenamespace">
<Report_Entry>
<Report_Date>
</Report_Date>
</Report_Entry>
<Report_Entry>
<Report_Date>
</Report_Date>
</Report_Entry>
<Report_Entry>
<Report_Date>
</Report_Date>
</Report_Entry>
</Report_Data>
Run Code Online (Sandbox Code Playgroud)
XSLT之后的输出是这样的:
<Report_Entry xmlns="examplenamespace">
<Report_Date>
</Report_Date>
</Report_Entry>
<Report_Entry xmlns="examplenamespace">
<Report_Date>
</Report_Date>
</Report_Entry>
<Report_Entry xmlns="examplenamespace">
<Report_Date>
</Report_Date>
</Report_Entry>
Run Code Online (Sandbox Code Playgroud)
问题是,每个Report_Entry标记现在从我删除的根节点获取该xml命名空间属性.
如果你想知道,我知道XSLT的输出结构不好.我稍后在XSLT转换后添加XML声明和不同的根节点名称.
我想知道是否可以有一个winforms程序,也可以从命令行运行?
我想要做的是创建一个发送电子邮件的简单Winform.该程序将从我已有的控制台应用程序中调用.但我也希望能够单独运行该程序.
这可能吗?
如果是这样,我如何从现有的控制台应用程序运行该程序?
我在C#中使用.NET 4.5.
我只是想知道是否有办法限制文件输入对话框只显示某些类型的文件.我的网页只能接受.bin或.gz文件类型,但用户可以选择其他文件类型并尝试上传它们.
什么是防止上传错误文件的最佳方法?
这是我的文件上传控制器:
public function uploadFile()
{
$this->Session->write('isFileUpload', false);
$this->Session->write('isFileLarge', false);
if($this->request->is('post'))
{
$uploadedFile = array();
// Check if the Document object is set
// If it is set, process the file for uploading,
if(isset($this->request->data['Document']))
{
$filename = $this->request->data['Document']['MyFile']['tmp_name'];
$uploadedFile['MyFile']['name'] = $this->request->data['Document']['MyFile']['name'];
$uploadedFile['MyFile']['type'] = $this->request->data['Document']['MyFile']['type'];
$uploadedFile['MyFile']['size'] = $this->request->data['Document']['MyFile']['size'];
// Move the file to the /home/spectracom folder
$filePath = DS . 'home' . DS . $uploadedFile['MyFile']['name'];
if (move_uploaded_file($filename, $filePath))
{
$this->Session->write('isFileUpload', true);
$this->Session->write('isFileLarge', false);
$this->redirect('/tools/upgradebackup');
}
else
{
$this->Session->write('isFileUpload', false);
$this->Session->write('isFileLarge', …Run Code Online (Sandbox Code Playgroud) 我正在用C#编写一个Windows窗体程序,我希望能够将信息保存到XML文件中.当我第一次创建XML文件时,我只想宣传声明
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Run Code Online (Sandbox Code Playgroud)
然后我想要的根节点称为"联系人".
最终文件应如下所示:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Contacts>
<Contact>
<Name>name</Name>
<Address>address</Address>
<Contact>
<Contacts>
Run Code Online (Sandbox Code Playgroud)
将有多个<Contact></Contact>元素.
我遇到的问题是我第一次创建XML文件.
我的XML操作在他们自己的类中.这是创建文件的方法:
public void createFile()
{
if (!File.Exists(fileName))
{
//Populate with data here if necessary, then save to make sure it exists
xmlFile = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XComment("XML File for storing " + RootName));
xmlFile.Save(FileName);
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试运行它时,我得到一个ArgumentNullException是未处理的错误.
任何想法如何实际获取文件中的数据并保存?谢谢
我正在写一个excel vba宏.
我有一个超过10,000行的大型工作表.其中一列具有此格式的日期:10/28/13 06:57单元格具有用于格式化的常规编号.
我想将它格式化为只有这种格式的四位数字:( mmdd上例中为1028)
这是我到目前为止在子程序中的内容:
' This subroutine formats the columns to what is necessary for output
Sub formatColumns()
' Set the LastRow variable to hold the last row number
lastRow = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
Dim cell As Range
For Each cell In Range("B3:B" & lastRow)
cell.NumberFormat = "mmdd;@"
Next
End Sub
Run Code Online (Sandbox Code Playgroud) c# ×3
cakephp ×3
.net ×2
winforms ×2
xml ×2
checkbox ×1
controller ×1
dialog ×1
echo ×1
excel ×1
excel-vba ×1
file ×1
file-type ×1
formatting ×1
html ×1
hyperlink ×1
javascript ×1
jquery ×1
linq ×1
linq-to-xml ×1
list ×1
mime ×1
php ×1
root-node ×1
syntax ×1
upload ×1
vba ×1
xelement ×1
xslt ×1