我在模型中有bool属性:
public bool IsExistSchedule {get; set;}
Run Code Online (Sandbox Code Playgroud)
在视图中我写了以下内容:
<div id="step1" data-schedule="@Model.IsExistSchedule">
...
</div>
Run Code Online (Sandbox Code Playgroud)
在生成的页面中data-schedule包含True值.
如何在javascript中正确使用此值?
例如,我想检查变量是否为真:
var isExist = $('#step1').attr('data-schedule');
if( isExist === "True")
do something
Run Code Online (Sandbox Code Playgroud)
我不喜欢这部分isExist === "True".我应该将它转换为bool可能是或其他东西.我担心在其他浏览器中变量可能包含其他值:true, True, "True", "true".
谢谢.
我有一个对象:
public class Ticket
{
public string EventName {get;set;}
public string Count {get;set;}
public string Price {get;set;}
... other properties;
}
Run Code Online (Sandbox Code Playgroud)
测试:
var tickets = new List<Ticket>();
tickets.Add(new Ticket {EventName = "Test", TicketCount = 1, Price = 100});
tickets.Add(new Ticket { EventName = "Test", TicketCount = 2, Price = 200 });
tickets.Add(new Ticket { EventName = "Test2", TicketCount = 1, Price = 50 });
Run Code Online (Sandbox Code Playgroud)
我想获得具有以下属性的匿名对象:EventName, TicketCount, Price
并按事件名称"分组".
对于上面的示例,结果必须是:
匿名对象必须包含两个记录:
EventName = Test, TicketCount = 3, Price = 300 …Run Code Online (Sandbox Code Playgroud) 我写了以下代码:
public class Log
{
public static void Info(string message, int arg)
{
Logger.Info(message, arg);
}
}
public class Task
{
public void StartTask()
{
var i =10;
Log.Info(" i = ", i);
}
}
Run Code Online (Sandbox Code Playgroud)
但是在日志文件中包含:
2012-09-17 10:41:00.0789 | Info | i=
Run Code Online (Sandbox Code Playgroud)
这是配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true">
<targets>
<target name="logfile" xsi:type="File" fileName="C:\KazbiletLog.txt" layout="${longdate} | ${level} | ${message} ${exception:format=ToString,StackTrace}${newline}" />
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="logfile" />
</rules>
</nlog>
Run Code Online (Sandbox Code Playgroud) 我有string包含价格的变量.例如,10000.我想用一千个分隔符的空间.
如显示10000的10 000,150000因为150 000
我怎么能这样做呢?
我有一个Model与LevelInfo属性:
public IEnumerable<Tuple<string, string, string>> LevelInfo { get; set; }
Run Code Online (Sandbox Code Playgroud)
在视图中我有一个JS函数:
function fillPath(level, color) {
$('[level=' + level).attr({ 'fill': color });
}
Run Code Online (Sandbox Code Playgroud)
现在我想迭代LevelInfo 并调用fillPath函数:
$(document).ready(function() {
@foreach (var info in Model.LevelInfo)
{
// How can I call JS function from here?
// i.e, fillPath(info.Item1, info.Item2)
}
});
Run Code Online (Sandbox Code Playgroud)
谢谢.
我有一个js文件.它包含以下代码:
$("#speedB").change(function () {
var date = $(this).val();
$('.fl_near a').removeClass('selected');
var clientId = $('#wiz_main').data('client');
var eventId = $('#wiz_main').data('event');
$.get('/desk/GetSessionScreen', { clientId: clientId, eventId: eventId, date: date }, function (data) {
$('#step1').html(data);
});
});
Run Code Online (Sandbox Code Playgroud)
speedB加载页面时页面上不存在id的元素中的问题.它出现在ajax请求之后.如何使用jQuery 1.7.2 (methodon`)为后来创建的元素绑定事件?谢谢.
我有一个包含以下文本的字符串:
[l=9;f=0;r=5;p=2]
可能有多个:
[l=9;f=0;r=5;p=2];[l=9;f=0;r=6;p=2]
我想得到字符串数组(第二个例子):
[l=9;f=0;r=5;p=2]
[l=9;f=0;r=6;p=2]
Run Code Online (Sandbox Code Playgroud)
我尝试了这个,但它分裂不正确:
Regex.Split(seat, "(?=])");
Run Code Online (Sandbox Code Playgroud)
PS.regexp不是强制性的.
我有一个被调用的基类BaseEvent和几个后代类:
public class BaseEvent {
// the some properties
// ...
}
[MapInheritance(MapInheritanceType.ParentTable)]
public class Film : BaseEvent {
// the some properties
// ...
}
[MapInheritance(MapInheritanceType.ParentTable)]
public class Concert : BaseEvent {
// the some properties
// ...
}
Run Code Online (Sandbox Code Playgroud)
我有一个代码BaseEvent在运行时创建实例:
BaseEvent event = new BaseEvent();
// assign values for a properties
// ...
baseEvent.XPObjectType = Database.XPObjectTypes.SingleOrDefault(
t => t.TypeName == "MyApp.Module.BO.Events.BaseEvent");
Run Code Online (Sandbox Code Playgroud)
现在,此事件将在BaseEvent列表视图中显示.
我想执行以下操作:当用户单击Edit按钮然后在列表视图查找字段中显示所有后代类型.当用户将记录更改保存ObjectType到选定值时.
我怎样才能做到这一点?
谢谢.
PS.这是asp.net应用程序.
我有以下xml:
<Places Count='50'>
<Place ID='1' Row='1' Place='1' Type='1' Fragment='0'></Place>
<Place ID='2' Row='1' Place='2' Type='1' Fragment='0'></Place>
<Place ID='3' Row='1' Place='3' Type='2' Fragment='0'></Place>
<Place ID='4' Row='1' Place='4' Type='2' Fragment='0'></Place>
<Place ID='5' Row='1' Place='5' Type='2' Fragment='0'></Place>
//other tags
</Places>
Run Code Online (Sandbox Code Playgroud)
我想得到Dictionary<int, int>以下内容:
1,2 // 0 element in the Dictionary (type =1; count = 2)
2,3; // 1 element in the Dictionary (type =2; count = 3)
Run Code Online (Sandbox Code Playgroud)
第一个参数是Typexml,第二个参数是这种类型的计数.
谢谢.
请问,我有一节课:
public class PersonalInfo
{
public string Firsname {get;set;}
public string Lastname {get;set;}
public string Email {get;set;}
public string Phone {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
数据来自文件.而且,我需要通过此属性从文件中选择数据:
private IList<PersonalInfo> FindByPersonalData(string firstName, string lastName, string email, string phone)
{
...
}
Run Code Online (Sandbox Code Playgroud)
有几个属性可以为空,但如果它们已填满,则按其搜索.我可以检查每一个组合,但它很难看.什么是最好的解决方案?
谢谢
我有一个WCF Web服务.我想从此服务发送电子邮件.有从WCF发送电子邮件的库吗?
我希望该库具有简单的调度程序,例如,每小时发送一次或类似的东西.找不到任何东西.
c# ×7
linq ×3
asp.net-mvc ×2
javascript ×2
asp.net ×1
devexpress ×1
email ×1
jquery ×1
nlog ×1
regex ×1
wcf ×1
web-services ×1
xaf ×1