我有一个列表,列表中也有列表.
我在父列表上设置样式但是我想要父母和子列表的不同样式但是它们混合在一起我不能分开它们.
HTML文件:
<ul id="accountNavigation">
<li><a href="#">Something</a></li>
<li id="userNavigation">
<img src="https://si0.twimg.com/profile_images/135460415/UAB_dragon_head_normal.png" alt=""/>
<a href="#">Username</a>
<div class="showme">
<ul id="userNavigationSubMenu">
<li>test</li>
<li>test</li>
<li>test</li>
<li>test</li>
<li>test</li>
<li>test</li>
<li>test</li>
</ul>
</div>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
CSS文件:
body{background:#ff0000;}
#accountNavigation{ list-style: none;float: right;height: 44px;}
#accountNavigation li{ float: left;color: #fff;height: 44px;}
#accountNavigation li:hover{ background: #ddd;cursor: pointer;}
#accountNavigation li a{ text-decoration: none;color: #fff;line-height: 44px;font-weight: bold;font-size: 13px;height: 44px;padding: 15px 27px 0 14px;outline: none;}
#accountNavigation li img{ position: absolute;top: 12px;left: 10px;width: 22px;height: 22px;}
#userNavigation{position: relative;}
#userNavigation a {padding-left: 38px !important;}
#userNavigation{}
#userNavigation:hover{} …Run Code Online (Sandbox Code Playgroud) 我想保护控制器操作,以便只有角色为"Admin"的用户可以进入.
我不使用角色/成员资格提供程序,一切都是自定义的.
到目前为止我这样做了:
public class CustomAuthorizeAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
var isAuthorized = base.AuthorizeCore(httpContext);
if (!isAuthorized)
return false;
string username = httpContext.User.Identity.Name;
UserRepository repo = new UserRepository();
return repo.IsUserInRole(username, "Admin");
}
}
Run Code Online (Sandbox Code Playgroud)
请注意,我在这里硬编码了"Admin".
我希望这是动态的.
这项工作现在:
[CustomAuthorize]
public ActionResult RestrictedArea()...
Run Code Online (Sandbox Code Playgroud)
但是我想要这样的东西:
[CustomAuthorize(Roles = "Admin")]
public ActionResult RestrictedArea()
Run Code Online (Sandbox Code Playgroud) 这是我第一次和json一起工作.我试图从我的动作方法返回Json:
public JsonResult Upload()
{
...
return Json(new { foo = "sos....sos....sos..."});
}
Run Code Online (Sandbox Code Playgroud)
但结果我得到的是我的消息包装在这个"pre"标签中.如何解析"foo"?
"<pre style="word-wrap: break-word; white-space: pre-wrap;">{"foo":"sos....sos....sos..."}</pre>"
Run Code Online (Sandbox Code Playgroud) 我正在尝试实现AjaxControlToolkit NoBot,但我总是从IsValid()方法得到错误(状态值总是InvalidBadResponse).我在这里错过了什么吗?
ASCX代码:
// buttons, textboxes etc.
<asp:NoBot ID="NoBot1"
runat="server"
CutoffMaximumInstances="5"
CutoffWindowSeconds="60"
ResponseMinimumDelaySeconds="2"
/>
Run Code Online (Sandbox Code Playgroud)
代码背后:
protected void Button1_Click(object sender, EventArgs e)
{
AjaxControlToolkit.NoBotState state;
if (!NoBot1.IsValid(out state))
{
Page page = HttpContext.Current.Handler as Page;
ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "alert('" + " BOT " + "');", true);
}
else
{ ...}
}
Run Code Online (Sandbox Code Playgroud)
更奇怪的是:我输入数据进行登录,然后点击asp按钮.NoBot状态是InvalidBadResponse失败的.但是,然后我点击浏览器的刷新按钮它要求我重新发送请求我说好,现在状态是有效的!为什么?
我需要谷歌地图只有街道名称.我不想删除像标记的巴士站,医院等的
东西.我可以使用什么命令来删除这些东西?
我创建了一个asp:Repeater我填充.ascx控件:
protected void Page_Load(object sender, EventArgs e)
{
Repeater1.DataSource = listOfData;
Repeater1.DataBind();
}
Run Code Online (Sandbox Code Playgroud)
在页面上我有:
<uc:Product runat="server"
ImportantData='<% #Eval("ImportantData") %>'
id="DetailPanel1" />
Run Code Online (Sandbox Code Playgroud)
里面Product.ascx.cs我有:
public int ImportantData{ get; set; }
protected void Page_Load(object sender, EventArgs e)
{
}
Run Code Online (Sandbox Code Playgroud)
在Product.ascx我有:
<asp:ImageButton ID="btn_Ok" runat="server"
onclick="btn_Ok_Click"
ImageUrl="~/image.png" />
Run Code Online (Sandbox Code Playgroud)
问题是当我点击图像按钮时出现错误:
A critical error has occurred. Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page...
Run Code Online (Sandbox Code Playgroud)
我试图将第一个代码更改为: …
我第一次使用Web API将我的移动应用程序连接到Web API.
我有MVC 5项目,我已经创建了API文件夹ProductsController.
namespace DDD.WebUI.API
{
public class ProductsController : ApiController
{
public string GetAllProducts()
{
return "Hello From WebAPI";
}
}
}
Run Code Online (Sandbox Code Playgroud)
我试图从浏览器访问此方法:
http://localhost:21879/DDD.WebUI/API/products/GetAllProducts
Run Code Online (Sandbox Code Playgroud)
但我得到了404.
这可能是一些愚蠢但却无法解决的问题:(
更新
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "DefaultApi",
url: "API/{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
Run Code Online (Sandbox Code Playgroud)
更新2
我有一点进展:我有更新 …
asp.net-mvc asp.net-web-api asp.net-web-api-routing asp.net-web-api2
我正在尝试DBGeography通过ado.net 插入类型,但是没有运气。
这是我得到的错误:
从对象类型System.Data.Entity.Spatial.DbGeography到已知的托管提供程序本机类型不存在映射。
要么:
指定的类型未在目标服务器上注册。System.Data.Entity.Spatial.DbGeography,EntityFramework,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089。
这是我从db获取它时所做的,并且工作正常:
dynamic temp = reader.GetValue(3);
var text = string.Format("POINT({0:R} {1:R})", temp.Long, temp.Lat);
var srid = temp.STSrid.Value;
this.Coordinates = System.Data.Entity.Spatial.DbGeography.PointFromText(text, srid);
Run Code Online (Sandbox Code Playgroud)
但是插入不起作用:
updateCommand.Parameters.AddWithValue("@Coordinates", store.Coordinates);
// or ...
SqlParameter p = new SqlParameter();
p.ParameterName = "@Coordinates";
p.Value = store.Coordinates;
p.SqlDbType = System.Data.SqlDbType.Udt;
p.UdtTypeName = "geography";
updateCommand.Parameters.Add(p);
Run Code Online (Sandbox Code Playgroud)
怎么了
我正在从画廊中挑选照片并上传到服务器但是几天后我注意到有些照片有扩展名,浏览器无法呈现这些图片.
1.有没有办法从上传的heic中提取照片?
2.如何反应原生我可以从这种格式获得jpeg?
I have a scrollview which content is larger than phone screen.
I scroll to the bottom and there I have function that reload content of that scrollview but first clear data source for it.
Reload function is connected to RefreshControl on scrollview.
But RefreshControl is not visible while loading data except when I slightly touch screen where content should be.
And this is only when I start reload from scrollview bottom.
I tried to scroll to top but it doesn't …
c# ×4
asp.net-mvc ×3
asp.net ×2
javascript ×2
react-native ×2
ado.net ×1
css ×1
google-maps ×1
html ×1
html-lists ×1
json ×1
nested ×1
nested-lists ×1
repeater ×1
sql-server ×1
sqlgeography ×1