我正在尝试弄清楚如何从使用javascript导航的ASP按钮进行URL路由。我的自定义路线代码是:
void RegisterCustomRoutes(RouteCollection routes)
{
routes.MapPageRoute(
"DocumentByViewerRoute",
"Document/{documentTitle}",
"~/Viewer.aspx"
);
}
我的导航:
<h3>View</h3>
Select a document to view or to search. <br />
<asp:DropDownList ID="ddlViewDocument" runat="server"
ItemType="ArchiveViewer.Models.DocumentMetadata"
SelectMethod="GetDocumentList"
DataTextField="DocumentTitle" DataValueField="DocumentID"
AppendDataBoundItems="true" ToolTip="Select a document to view..."
Height="40px" style="margin-top: 20px" Width="362px" >
<asp:ListItem Text="Please select a document to view..." Value="-1">
</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnViewDocument" runat="server"
Text="View Selected Document"
Height="40px" Width="220px"
OnClientClick="var s = $('[id$=ddlViewDocument] option:selected').val();
if (s != -1) { window.open('Viewer.aspx?doc=' + s)};return false;" />
如何重新编写按钮“ OnClientClick ”方法以使用网址?
之前有没有遇到过这个?我很茫然。