我正在尝试使用Repeater的OnItemCommand在新标签页(最好是)或新窗口中打开aspx页面。可以用OnItemCommand吗?
目前,它重定向到一个新的aspx页面就好了,但我留在同一个标签页。
这是我的标记代码:
angular.module('apitestApp')
.service('httpService', ['$rootScope', '$resource', '$localStorage', function ($rootScope, $resource, $localStorage) {
var self = this;
this.messages = undefined;
this.setPath = function () {
self.getRequest($rootScope.domainPath + $rootScope.apiPath + 'messages.json', {});
};
this.getRequest = function (url, params) {
var res = $resource(url, params, {
query: {
method: 'GET',
isArray: true,
headers: { 'Authorization': 'Bearer ' + $localStorage.token.access_token }
}
});
return res.query().$promise.then(function (data) {
if (data) {
self.messages = data;
$rootScope.$broadcast('messagesReady');
}
});
};
this.refreshToken = function (){
var url = $rootScope.domainPath + this.authPath;
var request = $resource(url);
return request.get({
client_id: this.clientId,
client_secret: this.secret,
grant_type: 'refresh_token',
refresh_token: $localStorage.token.refresh_token
},
function (data){
$localStorage.token = data;
}
).$promise;
};
this.onMessageReady = function (scope, callback) {
callback(this.messages);
scope.$on('messagesReady', function () {
callback(this.messages);
});
};
}]);
代码背后:
<asp:Repeater ID="someRepeater" runat="server"OnItemCommand="Repeater_ItemCommand">
<HeaderTemplate>
//bluh bluh
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="link1" runat="server" CommandName="Redirect" CommandArgument='<%#Eval("textID") %>'><asp:Label Enable="true" ID="textID" runat="server" Text='<%#Eval("textName") %>'></asp:Label></asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
//bluh bluh footer
</FooterTemplate>
</asp:Repeater>
谢谢,
答案 0 :(得分:0)
我将发布我继续使用代码的方式。可能会对某人有用。
<asp:Repeater ID="someRepeater" runat="server">
<HeaderTemplate>
//bluh bluh
</HeaderTemplate>
<ItemTemplate>
<a href= "~/Other.aspx?id=<%#Eval('textID') %>" target="_blank" />
</ItemTemplate>
<FooterTemplate>
//bluh bluh footer
</FooterTemplate>
</asp:Repeater>
这似乎可以解决问题。我没有使用转发器的OnItemCommand。不需要任何代码。
谢谢。