ASP.NET 1.1 - “<%=”和“%”在地址栏中呈现的标签

发布于 2024-10-05 09:56:19 字数 642 浏览 0 评论 0 原文

我继承了大约 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,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白鸥掠海 2024-10-12 09:56:19

您不能将 <%= 放入 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文