我继承了大约 8 年前编写的 ASP.NET 1.1 应用程序,该应用程序显然是某人第一次沉浸在 .NET 中,因为代码是代码隐藏以及分散在整个标记中的服务器端的混合体。
我遇到的问题是表单标签有一个如下所示的操作:
<form name="myForm" id="myForm" method="post" action="?id=<%= fooId %>" runat="server">
当保存按钮悬停在状态栏中时,我会看到:
?id=<%= fooId %>
与此相反:
?id=123
如果用户单击保存按钮,地址栏显示:
http://servername/virtdir/pagename.aspx?id=<%= fooid %>
这显然会导致应用程序抛出异常。我尝试过使用:
action="?id=<% Response.Write(fooId) %>"
但仍然遇到同样的问题。问题仅限于此页面,我还能尝试什么?
谢谢,
I inherited an ASP.NET 1.1 application that was written about 8 years ago, the app is obviously someone's first immersion in .NET as the code is a mixture of code-behind as well as server-side scattered throughout the markup.
The problem I'm having is that the form label has an action that looks like this:
<form name="myForm" id="myForm" method="post" action="?id=<%= fooId %>" runat="server">
When the save button is hovered over I see in the status bar:
?id=<%= fooId %>
As opposed to:
?id=123
If the user clicks the save button, the address bar shows:
http://servername/virtdir/pagename.aspx?id=<%= fooid %>
Which obviously causes the application to throw an exception. I've tried using:
action="?id=<% Response.Write(fooId) %>"
But still get the same problem. The problem is localized to this page, what else can I try?
Thanks,
发布评论
评论(1)
您不能将 <%= 放入 runat=server 标记中 - 您告诉它在服务器端代码已经存在时闯入服务器端代码。尝试在代码隐藏中以编程方式设置操作。
You can't put <%= into a runat=server tag - your telling it to break into server side code when it already is. Try setting the action programatically in the codebehind.