【问题标题】:ASP.NET ContentPage with Form Controls带有表单控件的 ASP.NET ContentPage
【发布时间】:2013-07-02 00:34:44
【问题描述】:

我创建了一个引用母版页的内容页。在内容页面中,我有一个表单和一些带有提交按钮的表单控件。当我点击提交时,虽然在内容页面的页面加载中未检测到参数。最重要的是参数的名称都搞砸了。

将表单控件添加到内容页面然后使用Request.QueryString[ID]的正确方法是什么?

我刚刚意识到,当您使用母版页时,Microsoft 会向您抛出各种额外的废话。这绝对是荒谬的,有没有办法让我不走这条使用各种愚蠢的铸造和低效开销的路线:

http://www.asp.net/web-forms/tutorials/master-pages/control-id-naming-in-content-pages-cs

我的代码(母版页):

<%@ Master Language="C#" AutoEventWireup="true" ClientIDMode="Static" %>

<!DOCTYPE html>
<html lang="en">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="Head" runat="server"></asp:ContentPlaceHolder>
</head>
<body>
    <asp:ContentPlaceHolder runat="server" ID="MainContent" />
</body>
</html>

我的代码(内容页面):

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <label for="iSiteId">Site Id(s)</label>
    <asp:TextBox ID="iSiteId" runat="server"></asp:TextBox>
    <label for="iVersion">Version(s)</label>
    <asp:TextBox ID="iVersion" runat="server"></asp:TextBox>
</asp:Content>

我的代码(内容页面,但背后的代码)

_siteId = Request.QueryString["iSiteId"];
_categoryId = Request.QueryString["iCategoryId"];
_version = Request.QueryString["iVersion"];

【问题讨论】:

  • 请添加您的代码。

标签: asp.net webforms master-pages content-pages


【解决方案1】:

试试这些:

siteId = iSiteId.Text;
_categoryId = iCategoryId.Text;
_version = iVersion.Text;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多