locked
master page RRS feed

  • Question

  • User-1889242635 posted

    i have created a project using aspwebsite for creating a  multilingual website.added a webform using master page named as RegisterForm.but getting an error:'Multilanguage.RegisterForm' is not allowed here because it does not extend class 'System.Web.UI.Page'.

    Source Error: line 1

    here is my aspx code:

    <%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="RegisterForm.aspx.cs" Inherits="Multilanguage.RegisterForm" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div style="text-align:right";>
    <asp:DropDownList ID="ddLang" runat="server" AutoPostBack="true" >

    <asp:ListItem Value="en-US" Text="English" />
    <asp:ListItem Value="fr-FR" Text="Francais" />
    <asp:ListItem Value="hi-IN" Text="हिन्दी" />
    </asp:DropDownList>
    </div>
    <table>
    <tr>
    <td>
    <asp:Label ID="lblName" runat="server" Text="Name" />
    </td>
    <td><asp:TextBox ID="txtName" runat="server" /></td>
    </tr>
    <tr>
    <td><asp:Label ID="lblAddress" runat="server" Text="Address"/></td>
    <td><asp:TextBox ID="txtAddress" runat="server" /></td>
    </tr>
    <tr>

    <td><asp:Label ID="lblState" runat="server" Text="State" /></td>
    <td><asp:TextBox ID="txtState" runat="server" /></td>
    </tr>
    <tr>

    <td><asp:Label ID="lblCountry" runat="server" Text="Country"/></td>
    <td><asp:TextBox ID="txtCountry" runat="server" /></td>
    </tr>
    <tr>
    <td></td>
    <td>
    <asp:Button ID="btnSave" runat="server" Text="Save" />&nbsp;
    &nbsp;
    <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
    </td>


    </tr>
    </table>

    </asp:Content>

    aspx.cs code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Resources;
    using System.Globalization;
    using System.Threading;
    using System.Reflection;

    namespace Multilanguage
    {
    public partial class RegisterForm : System.Web.UI.Page
    {
    ResourceManager rm;
    CultureInfo ci;

    protected void Page_Load(object sender, EventArgs e)
    {
    if(Session["Lang"]==null){
    Session["Lang"]=Request.UserLanguages[0];
    }
    if (!IsPostBack)
    {
    LoadString();

    }
    }

    private void LoadString()
    {

    Thread.CurrentThread.CurrentCulture = new CultureInfo(Session["Lang"].ToString());
    rm = new ResourceManager("Multilanguage.App_GlobalResource.Lang", Assembly.GetExecutingAssembly());
    ci = Thread.CurrentThread.CurrentCulture;

    lblName.Text = rm.GetString("Name", ci);
    lblAddress.Text = rm.GetString("Address", ci);
    lblCountry.Text = rm.GetString("Country", ci);
    lblState.Text = rm.GetString("State", ci);
    btnSave.Text = rm.GetString("Save", ci);
    btnCancel.Text = rm.GetString("Cancel", ci);
    }

    protected void ddLang_SelectedIndexChanged(object sender, EventArgs e)
    {
    //this is for change language
    Session["Lang"] = ddLang.SelectedValue;
    LoadString();
    }

    }
    }

    please do help me where ismy error as soon as possible thanks in advance 

    plss be fast

    Saturday, January 21, 2017 8:51 PM

All replies

  • User1169094377 posted

    plz clean the project and run again and also make sure your website is building or compiling successfully

    Saturday, January 21, 2017 9:46 PM
  • User-1889242635 posted

    i did try cleaning the project and rebuld it...its rebuild sucessfully but the error is same,pls do help

    Sunday, January 22, 2017 6:55 AM
  • User1169094377 posted

    try to add some other page with different name i.e. register.aspx

    Sunday, January 22, 2017 8:10 AM
  • User-2057865890 posted

    Hi Heenayamin,

    Could you post the master page code? You could refer following code snippets, it works well on my side. Besides, try to recreate the master and content page.

    Master Page

    <%@ Master Language="C#" AutoEventWireup="true"
        CodeFile="MasterPage.master.cs"
        Inherits="MasterPage" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title></title>
        <asp:ContentPlaceHolder ID="head" runat="server">
        </asp:ContentPlaceHolder>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                </asp:ContentPlaceHolder>
            </div>
        </form>
    </body>
    </html>
    

    Content Page

    <%@ Page Language="C#"
        MasterPageFile="~/MasterPage.Master"
        AutoEventWireup="true"
        CodeFile="testpage.aspx.cs"
        Inherits="Multilanguage.testpage" %>
    
    
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    </asp:Content>
    
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <asp:DropDownList ID="ddLang" runat="server" AutoPostBack="true">
            <asp:ListItem Value="en-US" Text="English" />
            <asp:ListItem Value="fr-FR" Text="Francais" />
            <asp:ListItem Value="hi-IN" Text="हिन्दी" />
        </asp:DropDownList>
    </asp:Content>
    
    

    reference: https://msdn.microsoft.com/en-us/library/ehszf8ax.aspx

    Best Regards,

    Chris

    Tuesday, January 24, 2017 9:14 AM