我想将Copyright @'current_year'添加到我页面的页脚(在cshtml文件中).我经常使用javascript制作它,但由于我使用ASP.NET MVC 3,我想使用ASP来做到这一点.
我正在尝试建设:
@response.write("Current Year: "&Year(Date))
Run Code Online (Sandbox Code Playgroud)
但它在MVC 3中不起作用,我找不到有效的解决方案.
我需要使用Javascript从location.href中删除域名.我有类似的链接:http://localhost/App/User/UserOrder.aspx?id=949abc91-a644-4a02-aebf-96da3ac7d8e1&type=MO
我需要没有链接http://localhost
,将来没有真正的域名.
我将在Javascript函数中使用这些trimed链接,所以我想在Javascript中修剪它.
我试过了:window.location.href.split('/')[2];
但我只能获得域名形式.我想摆脱域名.
任何帮助在这里非常感谢!
我需要使用textarea和图片上传字段制作表单.当有人提交它时,我希望它发送电子邮件(带有来自textarea的文本)和附件(从输入文件上传字段)给我.
我的简单形式看起来像这样:
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
@Html.TextArea("Question");
<input type="file"/>
<input type="submit" value="Send" />
</fieldset>
}
Run Code Online (Sandbox Code Playgroud)
我发现PHP脚本正在做类似的事情,但我怎么能在ASP.NET MVC中做到这一点(可能是用JavaScript)?
我在Javascript中有一个异步函数,我添加了setTimeout.代码看起来像这样:
let timer;
clearTimeout(timer);
timer =setTimeout(() => {
(async() => {
await this._doSomething();
})();
}, 2000);
Run Code Online (Sandbox Code Playgroud)
setTimeout的puprose是在运行函数之前加2秒.确保用户停止输入.
我现在应该从此函数中删除async/await,因为setTimeout是异步的吗?
任何帮助在这里非常感谢!
我在应用程序(.NET Framework 4,WPF)中有很多弹出窗口,我必须为所有这些设置一种样式.弹出窗口示例如下:
<Popup PopupAnimation="Fade" MinWidth="600" MinHeight="200" Placement="Center" VerticalAlignment="Center" HorizontalAlignment="Center" IsEnabled="True" IsOpen="False">
<Grid Width="Auto" Height="Auto" Background="Gray">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border BorderThickness="2" CornerRadius="8" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.RowSpan="2">
<Border.BorderBrush>
<SolidColorBrush Color="Gray"/>
</Border.BorderBrush>
<Border.Background>
<SolidColorBrush Color="White"/>
</Border.Background>
</Border>
<StackPanel Grid.Row="0">
<Label Foreground="Blue" Content="Popup_Title"/>
</StackPanel>
<GroupBox Grid.Row="1" Header="Popup example content">
<StackPanel>
...
</StackPanel>
</GroupBox>
</Grid>
</Popup>
Run Code Online (Sandbox Code Playgroud)
如何将边框和背景等样式添加到样式模板中?我无法使用TargetType Popup编写Style并修改它,Property="Template"
因为Popup Control没有Property="Template"
.那么我怎样才能为那些Popups写风格呢?
编辑: 确切的工作方式:
<Style x:Key="PopupContentStyle" TargetType="ContentControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ContentControl">
<Grid Width="Auto" Height="Auto" Background="Gray">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="Auto"/> …
Run Code Online (Sandbox Code Playgroud) 当我想使用SQL Server 2008 R2的预定义"CREATE TRIGGER"创建触发器时,我迷路了.你能给我一个直接的SQL语句,我可以用来创建一个触发器,并告诉我如何定义AFTER,BEFORE等等吗?
另外,如何知道行UPDATED/INSERTED/DELETED,并使用它们的列值在触发器内执行操作?
如何将垂直分隔符添加到WPF功能区,添加到RibbonGroup?我尝试了类似的东西,但我得到的是水平分隔符而不是垂直分隔符.
<r:RibbonGroup>
<r:RibbonButton Command="{StaticResource SomeButton}" />
<r:RibbonSeparator></r:RibbonSeparator>
<r:RibbonToggleButton IsChecked="False" Command="{StaticResource AnotherButton}"/></r:RibbonToggleButton>
</r:RibbonGroup>
Run Code Online (Sandbox Code Playgroud)
那么如何制作垂直分隔符呢?
我必须将选择列表添加到注册页面.我想在datebase中保存所选项目.我有类似的东西:
在视图页面中:
<%: Html.DropDownListFor(m => m.Profession, (IEnumerable<SelectListItem>)ViewData["ProfessionList"])%>
<%: Html.ValidationMessageFor(m => m.Profession)%>
Run Code Online (Sandbox Code Playgroud)
在模型类中:
[Required]
[DisplayName("Profession")]
public string Profession { get; set; }
Run Code Online (Sandbox Code Playgroud)
在控制器中:
ViewData["ProfessionList"] =
new SelectList(new[] { "Prof1", "Prof2", "Prof3", "Prof4", "Prof5"}
.Select(x => new { value = x, text = x }),
"value", "text");
Run Code Online (Sandbox Code Playgroud)
我收到错误:没有类型为'IEnumerable'的ViewData项具有关键'Profession'.
我能做些什么才能让它发挥作用?
我必须每天在太平洋时间午夜执行工作.我正在使用带有Quartz.NET库的MVC3.
这是我的代码:
public static void ConfigureQuartzJobs()
{
ISchedulerFactory schedFact = new StdSchedulerFactory();
IScheduler sched = schedFact.GetScheduler();
DateTime dateInDestinationTimeZone = System.TimeZoneInfo
.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, System.TimeZoneInfo.Utc.Id, "Pacific Standard Time").Date;
IJobDetail job = JobBuilder.Create<TimeJob>()
.WithIdentity("job1", "group1")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.StartAt(dateInDestinationTimeZone)
.WithSimpleSchedule(x => x.WithIntervalInHours(24).RepeatForever())
.Build();
sched.ScheduleJob(job, trigger);
sched.Start();
}
Run Code Online (Sandbox Code Playgroud)
此代码使此作业仅在第一个午夜(太平洋时间)运行一次.我已经在那里设置.WithSimpleSchedule(x => x.WithIntervalInHours(24).RepeatForever())
但它不起作用 - 工作不是每天都在重复.
我能做些什么让它每天都能运作?
任何帮助非常感谢!
我在我的应用程序资源文件刷:
<SolidColorBrush x:Key="MainColor" Color="#FF15428B" />
Run Code Online (Sandbox Code Playgroud)
我想在运行时更改此画笔的颜色.我添加了颜色选择器 - 当用户选择颜色时,我希望这个画笔具有选定的颜色.
我试过这样的代码:
SolidColorBrush MainColor = new SolidColorBrush(SelectedColor);
Run Code Online (Sandbox Code Playgroud)
但它没有用.
c# ×4
.net ×3
wpf ×3
javascript ×2
razor ×2
xaml ×2
asynchronous ×1
c#-4.0 ×1
forms ×1
html ×1
jquery ×1
popup ×1
quartz.net ×1
ribbon ×1
scheduling ×1
separator ×1
settimeout ×1
sql ×1
sql-server ×1
triggers ×1