var boxIdValue = 233;
var result = title + '<br/>@Html.ActionLink("Detail", "Show", "Boxes", new{boxId=233}, null)';
Run Code Online (Sandbox Code Playgroud)
当我硬编码boxId
然后它工作.但是当我写道:
var result = title + '<br/>@Html.ActionLink("Detail", "Show", "Boxes", new{boxId=boxIdValue}, null)';
Run Code Online (Sandbox Code Playgroud)
它没有.是否有可能以这种方式混合javascript var和razor?
我有控制器实现UIAlertViewDelegate.在实施中,我有:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
Run Code Online (Sandbox Code Playgroud)
方法.当我创建UIAlertView时,我将'委托'放到'self'中,它运行正常.但问题是,现在我还有一个警报视图,我希望每个视图都有不同的行为.那么如何检查哪个alertView发送消息?
我有一个json对象:
@interface Order : NSObject
@property (nonatomic, retain) NSString *OrderId;
@property (nonatomic, retain) NSString *Title;
@property (nonatomic, retain) NSString *Weight;
- (NSMutableDictionary *)toNSDictionary;
...
- (NSMutableDictionary *)toNSDictionary
{
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
[dictionary setValue:self.OrderId forKey:@"OrderId"];
[dictionary setValue:self.Title forKey:@"Title"];
[dictionary setValue:self.Weight forKey:@"Weight"];
return dictionary;
}
Run Code Online (Sandbox Code Playgroud)
在字符串中这是:
{
"Title" : "test",
"Weight" : "32",
"OrderId" : "55"
}
Run Code Online (Sandbox Code Playgroud)
我用代码获取字符串JSON:
NSMutableDictionary* str = [o toNSDictionary];
NSError *writeError = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:str options:NSJSONWritingPrettyPrinted error:&writeError];
NSString *jsonString = [[NSString alloc] …
Run Code Online (Sandbox Code Playgroud) 更新 1
我return
从代码中删除,现在链接在 IOS 上工作。但是在android上我无法打开任何应用程序。任何的想法?
我正在尝试从我的应用程序中打开不同的应用程序。
return Linking.openURL(“twitter://“);
return Linking.openURL(“instagram://“);
Run Code Online (Sandbox Code Playgroud)
但它不起作用。我通过文档配置了 IOS。在 android 上也不起作用。尽管...
return Linking.openURL(“tripadvisor://“);
Run Code Online (Sandbox Code Playgroud)
工作得很好。知道为什么我无法打开其他应用程序。
这是我正在使用的代码(如果已安装,则打开应用程序或使用它打开商店,但有时甚至商店都没有打开)我做错了什么:
let appUrl = "instagram://";
Linking.canOpenURL(appUrl).then(supported => {
if (!supported) {
Alert.alert("",
"",
[
{text: "go to store", onPress: this.openStorePress},
{text: "cancel", onPress: () => { }, style: 'cancel'},
],
{ cancelable: false }
);
} else {
return Linking.openURL(appUrl);
}
}).catch(err => {
console.error(err);
});
Run Code Online (Sandbox Code Playgroud) 我不想从代码创建DataSet并将其设置为crystal report的数据源.
如果我不需要,我不想在VS中创建DataSet xsd文件.只是纯粹的代码.
DataSet ds = new DataSet();
DataTable tbl = new DataTable();
DataColumn cln = new DataColumn();
// I fill row, columns, table and add it to ds object
...
Run Code Online (Sandbox Code Playgroud)
然后,当我需要报告时,我使用:
myReport.SetDataSource(ds);
Run Code Online (Sandbox Code Playgroud)
这里的问题是我不知道如何绑定这个报告?如何添加字段?
我有一个文本和二进制数据(图像).
我在用户点击时在地图上添加标记.
问题是我只想要一个标记,但现在每当我点击地图时都会添加新标记.
我试图删除它但没有任何反应:
var marker;
map.on('click', function (e) {
map.removeLayer(marker)
marker = new L.Marker(e.latlng, { draggable: true });
marker.bindPopup("<strong>" + e.latlng + "</strong>").addTo(map);
marker.on('dragend', markerDrag);
});
Run Code Online (Sandbox Code Playgroud) 我有一个来自coredata的列表对象,然后我从其中一个对象获取objectId:
let fetchedId = poi.objectID.URIRepresentation()
Run Code Online (Sandbox Code Playgroud)
现在我需要为这个特定的objectID获取实体.我尝试过类似的东西:
let entityDescription = NSEntityDescription.entityForName("Person", inManagedObjectContext: managedObjectContext!);
let request = NSFetchRequest();
request.entity = entityDescription;
let predicate = NSPredicate(format: "objectID = %i", fetchedId);
request.predicate = predicate;
var error: NSError?;
var objects = managedObjectContext?.executeFetchRequest(request,
error: &error)
Run Code Online (Sandbox Code Playgroud)
但我得到错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath objectID not found in entity <NSSQLEntity Person id=4>'
Run Code Online (Sandbox Code Playgroud) 我试图在Android项目中实现firebase但总是得到:
Google Play服务已过时. Requires 9877000 but found 9683480
我的graddle项目/ app文件看起来像:
...
compile 'com.google.firebase:firebase-core:9.8.0'
compile 'com.google.firebase:firebase-database:9.8.0'
compile 'com.google.firebase:firebase-auth:9.8.0'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
和
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.google.gms:google-services:3.0.0'
Run Code Online (Sandbox Code Playgroud)
我使用API 23和Target:Android 6.0(Google API)x86_64创建了Nexus S模拟器
内部模拟器Google App Services版本为9.6.83
我应该怎么做才能运行firebase,因为不知道要安装或更新的内容:/
我是android的新手,不知道我是否遗漏了一些小东西.
我有一个对象(这是一个属性数组,因为它是动态的,我不能将它拆分为多个属性),我保留在reducer中看起来像这样:
[
{type: list, elements: []}
{type: map, elements: []}
{type: wheelList, elements: []}
{type: chart, elements: []}
{type: dyna, elements: []}
...
]
Run Code Online (Sandbox Code Playgroud)
在一个组件中,我从商店获取它并访问它,如:
this.props.allElements
Run Code Online (Sandbox Code Playgroud)
然后对于每一个我渲染不同的组件(伪代码):
foreach (el in this.props.allElements) {
if (el == list) {
return <ListComponent elements={el.elements}>
}
if (el == map) {
return <MapComponent elements={el.elements}>
}
...
}
Run Code Online (Sandbox Code Playgroud)
这样每个组件只获得感兴趣的元素.
我的问题是关于性能和优化.
我的方法有什么好处吗?
我遇到了一些性能问题,所以检查我的组织
是否有错,如果可以改进则需要建议.
我有一些频繁的更新,有时候地图可以每秒更新一次.
因此,如果我仅更新地图元素并将其传递给操作以进行更新,则所有这些组件将再次运行渲染或仅运行观察地图.
UPDATE
但是更新map
我需要得到全本内容object
来自store
于action update only map
元素,然后整个更新的对象传递给reducer
.
所以只有地图被改变,其他人则没有.
react/redux足够智能,只更新数据更改的组件(在我的情况下映射).
行动:
export function getScreenElements() …
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) asp.net-mvc ×2
c# ×2
objective-c ×2
react-native ×2
android ×1
asp.net ×1
core-data ×1
dataset ×1
firebase ×1
ios ×1
iphone ×1
javascript ×1
json ×1
leaflet ×1
nsdictionary ×1
razor ×1
react-redux ×1
reactjs ×1
redux ×1
swift ×1
uialertview ×1