我是jQuery的新手,需要一些过滤类的帮助.用户可以从九个按钮中进行选择,以选择要显示/隐藏的事件类型.单击一种颜色,仅显示具有该颜色的事件,其余部分将隐藏.点击"全部",所有事件都显示没有隐藏.所有活动都从一开始display:block.
示例控制按钮:
<li class="all" id="all-events"><a href="#" onclick="showEvents('event-all')">
<img src="swatch-all.png" alt="" /></a></li>
<li class="red" id="red-events"><a href="#" onclick="showEvents('event-red')">
<img src="swatch-red.png" alt="" /></a></li>
<li class="blue" id="blue-events"><a href="#" onclick="showEvents('event-blue')">
<img src="swatch-blue.png" alt="" /></a></li>
Run Code Online (Sandbox Code Playgroud)
这些事件是通过php从数据库中提取出来的,如下例所示:
<div id="bigCal">
<p class="all"><a href="http://foo.com" title="All event">All events</a></p>
<p class="blue"><a href="http://bar.com" title="Blue event">Blue event</a></p>
<p class="red"><a href="http://foobar.com" title="Red event">Red event</a></p>
</div>
Run Code Online (Sandbox Code Playgroud)
我已经在jQuery上工作了两天!不确定是否使用.filter或.hasClass或.is.它都不起作用.我试过的最简单的是:
function showEvents(color) {
($('p').hasClass(color)) ? this.style.display="block" : this.style.display="none";
}
Run Code Online (Sandbox Code Playgroud)
另一种无所作为的尝试是
function showEvents(color){
$("p[className*='event-']").css('display', 'none');
$("p[className=color]").css('display', 'block');
if ($("p[className='event-all']"))
$("p[className*='event-']").css('display', 'block'); …Run Code Online (Sandbox Code Playgroud) 我有一个局部视图需要在ActionLink中包装图像,所以当用户点击它时,它将去编辑图像.我有一个名为img.ashx的内容处理程序.
这是我的图像文字:
这是我的ActionLink:@ Html.ActionLink(item.Title,"EditMediaItem",new {location = item.Location,id = item.Id})
如何才能做到这一点?
提前致谢.
我有一个带有DataGridView的表单,我想使用DataSet将XML文件中的数据加载到Grid中.我创建一个DataSet,将XML加载到DataSet中,然后将DataSet分配给Grid的DataSource属性:
private void formAccountHistory_Load(object sender, EventArgs e)
{
// Load the DataSet that represents the offline version of the database.
AccountHistoryDS = new DataSet("TicketAccountHistory");
AccountHistoryDS.ReadXmlSchema("TicketsAccountHistory.xsd");
AccountHistoryDS.ReadXml("TicketsAccountHistory.xml", XmlReadMode.Auto);
AccountHistoryDS.Locale = System.Globalization.CultureInfo.CurrentUICulture;
dataGridViewStatement.AutoGenerateColumns = false;
dataGridViewStatement.DataSource = AccountHistoryDS;
dataGridViewStatement.DataMember = "Line";
}
Run Code Online (Sandbox Code Playgroud)
但是,数据不会显示在网格中.我在XML文件中有8行,而Grid创建了8行,但它们都是空白的.当我调试代码时,我可以看到DataSet中的数据,所以它似乎正确加载到那一点,只是没有在Grid中显示它.我使用的XML文件如下所示 - 它格式正确,并根据其架构进行验证:
<?xml version="1.0" standalone="yes"?>
<TicketsAccountHistory>
<Line>
<colID>03/09</colID>
<colStartEnd>14/01/2009-20/01/2009</colStartEnd>
<colDate>14/01/2009</colDate>
<colType>Period 03/09 - opening balance</colType>
<colDR></colDR>
<colCR></colCR>
<colBalance>0.00</colBalance>
</Line>
<Line>
<colID>03/09</colID>
<colStartEnd>14/01/2009-20/01/2009</colStartEnd>
<colDate>20/01/2009</colDate>
<colType>Sales Invoice (Ref: MRO-S-03/09)</colType>
<colDR>1000</colDR>
<colCR></colCR>
<colBalance>1000.00</colBalance>
</Line>
<Line>
<colID>03/09</colID>
<colStartEnd>14/01/2009-20/01/2009</colStartEnd>
<colDate>20/01/2009</colDate>
<colType>Commission Invoice (Ref: MRO-C-03/09)</colType> …Run Code Online (Sandbox Code Playgroud) 当用户上传图像时,有没有办法可以加载图像客户端并在将其上传到服务器之前首先显示给他们?最好只使用javascript/jquery,但使用flash也是可以接受的.
我有一个Web表单,允许用户根据传入proc的参数搜索和编辑Oracle表中的记录.这是我的数据:
CAE_SEC_ID SEC_CODE APPR_STATUS
1 ABC1 100
2 ABC2 100
3 ABC3 101
4 (null) 101
5 (null) 102
6 ABC4 103
Run Code Online (Sandbox Code Playgroud)
这是where子句:
select foo
from bar
where CAE_SEC_ID = NVL(p_cae_sec_id,CAE_SEC_ID)
and Upper(SEC_CODE) like '%' || Upper(NVL(p_sec_code,SEC_CODE)) || '%'
and APPR_STATUS = NVL(p_appr_status, APPR_STATUS)
Run Code Online (Sandbox Code Playgroud)
如果任何参数具有值,则对参数使用nvl应仅返回匹配的记录,如果所有参数都没有值,则应返回所有记录.所有相当标准或我认为.但是,当我在没有任何参数值的情况下进行搜索时,查询不会返回具有空SEC_CODE的记录,即仅返回记录1,2,3和6.上面的where子句不应该包含具有空SEC_CODE值的记录吗?
我一直在寻找关于如何做到这一点的不同线程,并将下面的脚本放在一起,但是,即使我输入输入所以它们不是空的,我也会弹出警报并且表单不会提交.
谁能看到我做错了什么,或者是否有更简单/更有效的方法呢?
谢谢,
奥苏
HTML:
<form action="#" method="post" class="signup-form">
<div class="required">
<label for="name">Name:</label>
<input type="text" name="cm-name" id="name" value=""><br />
</div>
<div class="required">
<label for="asd-asd">Email:</label>
<input type="text" name="cm-asd" id="asd-asd" value="">
<span class="btn"><input type="submit" name="submit" value="" id="signup"></span>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
JS:
// Validate form fields in Sign up form
$(".signup-form").submit(function(){
var isFormValid = true;
$(".signup-form .required input").each(function(){
if ($.trim($(this).val()).length == 0){
$(this).parent().addClass("highlight");
isFormValid = false;
} else {
$(this).parent().removeClass("highlight");
}
});
if (!isFormValid) alert("Please fill in all the required fields (highlighted in red)"); …Run Code Online (Sandbox Code Playgroud) 我需要从原始图像创建缩略图,并且需要将两个图像都保存在本地文件夹中。我正在使用html文件控件上传图像
<input type="file" class="form-control" asp-for="ImageName" name="ProductImage" id="ProductImage">
Run Code Online (Sandbox Code Playgroud)
到提交表单时,我得到了 IFromFile
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(Guid id, ProductDTO product, IFormFile
ProductImage)
{
if (ModelState.IsValid)
{
byte[] fileBytes;
using (var ms = new MemoryStream())
{
ProductImage.CopyTo(ms);
fileBytes = ms.ToArray();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我已将其转换为byte []并将其传递给我的一种保存方法。在这里我需要特定图像的缩略图
到目前为止,我尝试过的是添加 package Install-Package System.Drawing.Common -Version 4.5.1
并创建了一种转换图像的方法
public string ErrMessage;
public bool ThumbnailCallback()
{
return false;
}
public Image GetReducedImage(int Width, int Height, Image ResourceImage)
{
try
{
Image ReducedImage;
Image.GetThumbnailImageAbort callb = new Image.GetThumbnailImageAbort(ThumbnailCallback);
ReducedImage = ResourceImage.GetThumbnailImage(Width, Height, …Run Code Online (Sandbox Code Playgroud) 所以一个难题,我有一个名为 T_GROUP 的 Oracle 表。表中的记录具有唯一 ID (ID),它们是研究的一部分,由 STUDY_ID 标识,因此多个组可以在同一个研究中。
CREATE TABLE T_GROUP
(
"ID" NUMBER(10,0),
"GROUP_NAME" VARCHAR2(255 CHAR),
"STUDY_ID" NUMBER(10,0)
)
Run Code Online (Sandbox Code Playgroud)
现有表有数百条记录,我现在添加一个名为 GROUP_INDEX 的新列:
ALTER TABLE T_GROUP ADD (
GROUP_INDEX NUMBER(10,0) DEFAULT(0)
);
Run Code Online (Sandbox Code Playgroud)
添加列后,我需要运行一个脚本来更新 GROUP_INDEX 字段:它应该从 1 开始,并为研究中的每个组增加 1 ,从最低的 ID 开始。
所以现在我有如下数据:
ID GROUP_NAME STUDY_ID GROUP_INDEX
-------------------------------------------
1 Group 1 3 0
2 Group 2 3 0
3 My Group 5 0
4 Big Group 5 0
5 Group X 5 0
6 Group Z 6 0 …Run Code Online (Sandbox Code Playgroud) 我试图在MVC项目上实现审计跟踪,通过添加另一个功能来覆盖上下文(以便审计).SaveChanges的重写工作正常,但我遇到的问题是SaveChangesAsync.这是上下文中的代码的一部分
public override Task<int> SaveChangesAsync()
{
throw new InvalidOperationException("User ID must be provided");
}
public override int SaveChanges()
{
throw new InvalidOperationException("User ID must be provided");
}
public async Task<int> SaveChangesAsync(int userId)
{
DecidSaveChanges(userId);
return await this.SaveChangesAsync(CancellationToken.None);
}
public int SaveChanges(int userId)
{
DecidSaveChanges(userId);
return base.SaveChanges();
}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是我的控制器
await db.SaveChangesAsync(1);
Run Code Online (Sandbox Code Playgroud)
1是虚拟用户.我收到以下错误.
Error 1 The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task<System.Web.Mvc.ActionResult>'.
Run Code Online (Sandbox Code Playgroud)
你知道我在做错了什么吗?以及如何解决它?我正在使用EF6和MVC5
I have a static class in the production. For some reason, we need to replace the logging part methods in this class.(Still a static class unchanged)
Now I want to pass a logger to it. The logger is from another class.
public static class OutputUtils
public static void LogInfo(string logMessage)
{
logger.LogInfo(logMessage);
}
Run Code Online (Sandbox Code Playgroud)
In another class, I have
private readonly ILogger _logger;
public AnotherClass(ILogger logger)
{
_logger = logger;
}
internal static void LogDebug(string logMessage)
{
OutputUtils.LogInfo(logMessage);
}
Run Code Online (Sandbox Code Playgroud)
是的,我想传递_logger …
在 Blazor 中,我设置了两个 HttpClient。一份用于我的 API,一份用于 MS Graph API。Graph API 是新的,它迫使我找到一种将命名的 httpclient 注入到我的服务中的方法。
这是Main中的所有代码
public class Program
{
public static async Task Main(string[] args)
{
var b = WebAssemblyHostBuilder.CreateDefault(args);
b.RootComponents.Add<App>("app");
var samsonApiUrl = new Uri(b.HostEnvironment.BaseAddress + "api/");
b.Services.AddHttpClient("SamsonApi",client =>
{
client.BaseAddress = samsonApiUrl;
// add jwt token to header
// add user agent to header
}).AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();
b.Services.AddTransient<GraphCustomAuthorizationMessageHandler>();
b.Services.AddHttpClient<GraphHttpClientService>("GraphAPI",
client => client.BaseAddress = new Uri("https://graph.microsoft.com/"))
.AddHttpMessageHandler<GraphCustomAuthorizationMessageHandler>();
b.Services.AddScoped(provider => provider.GetService<IHttpClientFactory>().CreateClient("SamsonApi"));
b.Services.AddScoped(provider => provider.GetService<IHttpClientFactory>().CreateClient("GraphAPI"));
b.Services.AddMsalAuthentication<RemoteAuthenticationState, CustomUserAccount>(options =>
{
b.Configuration.Bind("AzureAd", options.ProviderOptions.Authentication);
options.ProviderOptions.DefaultAccessTokenScopes.Add("1c8d4e31-97dd-4a54-8c2b-0d81e4356bf9/API.Access");
options.UserOptions.RoleClaim = "role"; …Run Code Online (Sandbox Code Playgroud) c# ×4
jquery ×3
image ×2
oracle ×2
.net-core ×1
class ×1
datagridview ×1
filter ×1
form-submit ×1
javascript ×1
nvl ×1
plsql ×1
scrutor ×1
show-hide ×1
sql ×1
sql-update ×1
thumbnails ×1
validation ×1
winforms ×1