문제

I created a content page that references a master page. In the content page I have a form and some form controls with a submit button. When I hit submit though the parameters are not detected on page load in the content page. On top of that the name of the parameters are all messed up.

What is the correct way of adding form controls to the content page and then using Request.QueryString[ID]?

I just realized that Microsoft throws all kinds of extra crap at you when you use master pages. It is absolutely ridiculous, is there a way for me not to go down this route of using all kinds of silly casting and inefficient overhead:

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

My code (MASTER PAGE):

<%@ 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>

My code (Content Page):

<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>

My Code (Content Page but the Code behind)

_siteId = Request.QueryString["iSiteId"];
_categoryId = Request.QueryString["iCategoryId"];
_version = Request.QueryString["iVersion"];
도움이 되었습니까?

해결책

Try these instead:

siteId = iSiteId.Text;
_categoryId = iCategoryId.Text;
_version = iVersion.Text;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top