Solved

Cannot access the user control in aspx page.

Posted on 2010-09-16
4
956 Views
Last Modified: 2012-05-10
The aspx page does not see the user control.

Any help would be appreciated.

I have the following aspx page:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PrivateMessaging.Controls;

public partial class SendMessage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check license


        // Initializes page title control
        //CurrentMaster.Title.TitleText = ResHelper.GetString("messaging.sendmessage");
        //CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Messaging/sendmessage.png");
        //Title = "Send Message"; //ResHelper.GetString("messaging.sendmessage");

        int requestedUserId = 1; // QueryHelper.GetInteger("requestid", 0);
        if (requestedUserId != 0)
        {
            //UserInfo requestedUser = UserInfoProvider.GetFullUserInfo(requestedUserId);
            string fullUserName = null; // HTMLHelper.HTMLEncode(UserInfoProvider.GetFullUserName(Functions.GetFormattedUserName(requestedUser.UserName, true), requestedUser.UserNickName));
            Page.Title = "Sending Message To"; // ResHelper.GetString("messaging.sendmessageto") + " " + fullUserName;
            //CurrentMaster.Title.TitleText = Page.Title;
        }

        // Initilaize new message
        //SendMessage.DefaultRecipient = QueryHelper.GetString("requestid", string.Empty);
        //SendMessage.SendButtonClick += SendButon;
        //SendMessage.CloseButtonClick += CloseButon;
        //SendMessage.SendMessageMode = CMSModules_Messaging_Controls_SendMessage.SendMessageEnum.NewMessage;
        //SendMessage.DisplayCloseButton = true;
        //SendMessage.UsePromptDialog = false;
    }


    private void SendButon(object sender, EventArgs e)
    {
        if (uxSendMessage.ErrorMessage == string.Empty)
        {
            uxSendMessage.SendButton.Enabled = false;
            uxSendMessage.BBEditor.Enabled = false;
            uxSendMessage.SubjectBox.Enabled = false;
            uxSendMessage.FromBox.Enabled = false;
            uxSendMessage.CancelButton.Attributes.Add("onclick", "wopener.location.replace(wopener.location);");
            uxSendMessage.CancelButton.ResourceString = "general.Close";
        }
    }


    private void CloseButon(object sender, EventArgs e)
    {
        // Close
        ScriptHelper.RegisterStartupScript(this, GetType(), "closeSendDialog", ScriptHelper.GetScript("window.close();"));
    }

}

----------------------------------------------------------------------------

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SendMessage.aspx.cs" Inherits="PrivateMessaging.Messaging.MyMessages.SendMessage" %>

<%@ Register src="../../Controls/SendMessage.ascx" tagname="uxSendMessage" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
   <div class="MessagingBox MessagingDialog">
       <uc1:uxSendMessage ID="uxSendMessage" Visible="true" runat="server" />
    </div>
    </form>
</body>
</html>

errors:
Error	4	The name 'uxSendMessage' does not exist in the current context	C:\inetpub\wwwroot\PrivateMessaging\PrivateMessaging\Messaging\MyMessages\SendMessage.aspx.cs	42	13	PrivateMessaging

Open in new window

here is the user control
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PrivateMessaging.Controls
{
    public partial class SendMessage : System.Web.UI.UserControl
    {
        #region "Protected & private variables"

        /// <summary>
        /// Enumeration for send message mode
        /// </summary>
        public enum SendMessageEnum
        {
            Unasigned = 0,
            NewMessage = 1,
            ReplyMessage = 2,
            ForwardMessage = 3
        }


        protected string mMessageSubject = null;
        protected string mMessageBody = null;
        protected bool isAnonymousUser = false;
        //protected CurrentUserInfo currentUser = CMSContext.CurrentUser;

        private bool mAllowAnonymousUsers = true;
        private bool mAllowAnonymousRecipientSelection = true;
        private string mDefaultRecipient = "";
        private string mErrorMessage = "";

        #endregion


        #region "Public events"

        /// <summary>
        /// Event for send button click
        /// </summary>
        public event EventHandler SendButtonClick;


        /// <summary>
        /// Event for close button click
        /// </summary>
        public event EventHandler CloseButtonClick;

        #endregion


        #region "Public properties"

        /// <summary>
        /// Display close button
        /// </summary>
        public bool DisplayCloseButton
        {
            get
            {
                return btnClose.Visible;
            }
            set
            {
                btnClose.Visible = value;
            }
        }


        /// <summary>
        /// Related message ID
        /// </summary>
        //public int MessageId
        //{
        //    get
        //    {
        //        return ValidationHelper.GetInteger(ViewState["MessageId"], 0);
        //    }
        //    set
        //    {
        //        ViewState["MessageId"] = value;
        //    }
        //}


        /// <summary>
        /// Error message
        /// </summary>
        public string ErrorMessage
        {
            get
            {
                return mErrorMessage;
            }
            set
            {
                mErrorMessage = value;
            }
        }


        /// <summary>
        /// Send message mode
        /// </summary>
        public SendMessageEnum SendMessageMode
        {
            get
            {
                object sendMessageMode = ViewState["SendMessageMode"];
                return (sendMessageMode != null)
                           ? (SendMessageEnum)Enum.Parse(typeof(SendMessageEnum), sendMessageMode.ToString())
                           : SendMessageEnum.Unasigned;
            }
            set
            {
                ViewState["SendMessageMode"] = value;
            }
        }


        /// <summary>
        /// Paste original message
        /// </summary>
        //public bool PasteOriginalMessage
        //{
        //    get
        //    {
        //        return ValidationHelper.GetBoolean(ViewState["PasteOriginalMessage"], true);
        //    }
        //    set
        //    {
        //        ViewState["PasteOriginalMessage"] = value;
        //    }
        //}


        /// <summary>
        /// True if anonymous users should be able to send messages
        /// </summary>
        public bool AllowAnonymousUsers
        {
            get
            {
                return mAllowAnonymousUsers;
            }
            set
            {
                mAllowAnonymousUsers = value;
            }
        }


        /// <summary>
        /// True if anonymous users should be able to select recipient fo the messages
        /// </summary>
        public bool AllowAnonymousRecipientSelection
        {
            get
            {
                return mAllowAnonymousRecipientSelection;
            }
            set
            {
                mAllowAnonymousRecipientSelection = value;
            }
        }


        /// <summary>
        /// Default recipient of the message
        /// </summary>
        public string DefaultRecipient
        {
            get
            {
                return mDefaultRecipient;
            }
            set
            {
                mDefaultRecipient = value;
            }
        }


        /// <summary>
        /// Message subject
        /// </summary>
        public string MessageSubject
        {
            get
            {
                return mMessageSubject;
            }
            set
            {
                mMessageSubject = value;
            }
        }


        /// <summary>
        /// Message body
        /// </summary>
        public string MessageBody
        {
            get
            {
                return mMessageBody;
            }
            set
            {
                mMessageBody = value;
            }
        }


        /// <summary>
        /// Use prompt dialog
        /// </summary>
        //public bool UsePromptDialog
        //{
        //    get
        //    {
        //        return ucBBEditor.UsePromptDialog;
        //    }
        //    set
        //    {
        //        ucBBEditor.UsePromptDialog = value;
        //    }
        //}


        /// <summary>
        /// Information text
        /// </summary>
        public string InformationText
        {
            get
            {
                return lblSendInfo.Text;
            }
        }


        /// <summary>
        /// Errror text
        /// </summary>
        public string ErrorText
        {
            get
            {
                return lblSendError.Text;
            }
        }


        /// <summary>
        /// Send button
        /// </summary>
        //public LocalizedButton SendButton
        //{
        //    get
        //    {
        //        return btnSendMessage;
        //    }
        //}


        /// <summary>
        /// Cancel button
        /// </summary>
        //public LocalizedButton CancelButton
        //{
        //    get
        //    {
        //        return btnClose;
        //    }
        //}


        /// <summary>
        /// BB editor
        /// </summary>
        //public BBEditor BBEditor
        //{
        //    get
        //    {
        //        return ucBBEditor;
        //    }
        //}


        /// <summary>
        /// Box with subject
        /// </summary>
        public TextBox SubjectBox
        {
            get
            {
                return txtSubject;
            }
        }


        /// <summary>
        /// Box with "From" item
        /// </summary>
        public TextBox FromBox
        {
            get
            {
                return txtFrom;
            }
        }

        #endregion


        #region "Page events"

        /// <summary>
        /// Load page.
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Event arguments</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //ucMessageUserSelector.IsLiveSite = IsLiveSite;
            ReloadData();
        }


        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            //ucBBEditor.TextArea.CssClass = "BodyField";

            // Dialogs mode
            if (DisplayCloseButton)
            {
                pnlButtons.CssClass += " PageFooterLine";
                pnlSubPanel.CssClass = "FloatRight";
            }
        }

        #endregion


        #region "Other methods"

        /// <summary>
        /// Reload data
        /// </summary>
        public void ReloadData()
        {
            //if (StopProcessing)
            //{
            //    // Do nothing
            //}
            //else
            //{
            //    // WAI validation
            //    lblText.AssociatedControlClientID = ucBBEditor.TextArea.ClientID;

                // Default settings
                lblSendInfo.Visible = false;
                lblSendError.Visible = false;
                pnlSendMessage.Visible = true;
                pnlNoUser.Visible = false;

                //if (currentUser.IsAuthenticated() || AllowAnonymousUsers)
                //{
                //    // Decide if the user is anonymous
                //    isAnonymousUser = currentUser.IsPublic();

                    // Change controls
                    if (isAnonymousUser)
                    {
                        lblFrom.Visible = false;
                        txtFrom.Visible = true;
                    }
                    else
                    {
                        lblFrom.Visible = true;
                        //string userName = Functions.GetFormattedUserName(currentUser.UserName, IsLiveSite);
                        //lblFrom.Text = HTMLHelper.HTMLEncode(UserInfoProvider.GetFullUserName(userName, currentUser.UserNickName));
                        txtFrom.Visible = false;
                    }

                    // Reacting on the message
                    //if (MessageId != 0)
                    //{
                    //    // Get message
                    //    MessageInfo message = MessageInfoProvider.GetMessageInfo(MessageId);
                    //    if (message != null)
                    //    {
                    //        UserInfo sender = UserInfoProvider.GetUserInfo(message.MessageSenderUserID);
                    //        // Reply
                    //        switch (SendMessageMode)
                    //        {
                    //            case SendMessageEnum.ReplyMessage:
                    //                if (sender != null)
                    //                {
                    //                    hdnUserId.Value = sender.UserID.ToString();

                    //                    // Set message subject
                    //                    MessageSubject += message.MessageSubject;
                    //                    // Set message body
                    //                    if (currentUser.UserSignature.Trim() != string.Empty)
                    //                    {
                    //                        MessageBody += "\n\n\n" + currentUser.UserSignature;
                    //                    }
                    //                    if (PasteOriginalMessage)
                    //                    {
                    //                        MessageBody += "\n\n// " + message.MessageBody.Replace("\n", "\n// ");
                    //                    }

                    //                    // Set recipient
                    //                    lblTo.Text = HTMLHelper.HTMLEncode(UserInfoProvider.GetFullUserName(Functions.GetFormattedUserName(sender.UserName, IsLiveSite), sender.UserNickName));
                    //                    lblTo.Visible = true;
                    //                    ucMessageUserSelector.Visible = false;
                    //                }
                    //                else
                    //                {
                    //                    pnlNoUser.Visible = true;
                    //                    pnlSendMessage.Visible = false;
                    //                    lblNoUser.Text = ResHelper.GetString("SendMessage.NoUser");
                    //                }
                    //                break;

                    //            case SendMessageEnum.ForwardMessage:
                    //                MessageSubject += message.MessageSubject;
                    //                string signature = (currentUser.UserSignature.Trim() != "") ? "\n\n\n" + currentUser.UserSignature : "";
                    //                MessageBody += signature + "\n\n// " + message.MessageBody.Replace("\n", "\n//");
                    //                lblTo.Visible = false;
                    //                ucMessageUserSelector.Visible = true;
                    //                break;
                    //        }
                    //    }
                    //}
                    // New message
            //        else if (SendMessageMode == SendMessageEnum.NewMessage)
            //        {
            //            if (isAnonymousUser)
            //            {
            //                lblTo.Visible = !AllowAnonymousRecipientSelection;
            //                ucMessageUserSelector.Visible = AllowAnonymousRecipientSelection;
            //                if (!AllowAnonymousRecipientSelection)
            //                {
            //                    string userName = UserInfoProvider.GetUserNameById(ValidationHelper.GetInteger(DefaultRecipient, 0));
            //                    userName = Functions.GetFormattedUserName(userName, this.IsLiveSite);

            //                    lblTo.Text = HTMLHelper.HTMLEncode(userName);
            //                    hdnUserId.Value = DefaultRecipient;
            //                }
            //            }
            //            else if (DefaultRecipient != "")
            //            {
            //                lblTo.Visible = true;
            //                ucMessageUserSelector.Visible = false;
            //                string userName = UserInfoProvider.GetUserNameById(ValidationHelper.GetInteger(DefaultRecipient, 0));
            //                userName = Functions.GetFormattedUserName(userName, this.IsLiveSite);

            //                lblTo.Text = HTMLHelper.HTMLEncode(userName);
            //                hdnUserId.Value = DefaultRecipient;

            //                // Add signature
            //                if (currentUser.UserSignature.Trim() != "")
            //                {
            //                    MessageBody += "\n\n\n" + currentUser.UserSignature;
            //                }
            //            }
            //            else
            //            {
            //                lblTo.Visible = false;
            //                ucMessageUserSelector.Visible = true;

            //                // Add signature
            //                if (currentUser.UserSignature.Trim() != "")
            //                {
            //                    MessageBody += "\n\n\n" + currentUser.UserSignature;
            //                }
            //            }
            //        }

            //        // Initialize subject and body
            //        if (txtSubject.Text == string.Empty)
            //        {
            //            txtSubject.Text = MessageSubject;
            //        }
            //        if (ucBBEditor.Text == string.Empty)
            //        {
            //            ucBBEditor.Text = MessageBody;
            //        }
            //    }
            //    else
            //    {
            //        Visible = false;
            //    }
            //}
        }


        private bool ValidateBody(string body)
        {
            return true;
           // return ((body.Trim() != string.Empty) && (body.Trim().ToLower() != currentUser.UserSignature.Trim().ToLower()));
        }

        #endregion

    }
}

------------------------
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SendMessage.ascx.cs"
    Inherits="PrivateMessaging.Controls.SendMessage" %>
<asp:Panel ID="pnlSendMessage" runat="server" CssClass="SendMessage">
    <asp:Label ID="lblSendInfo" runat="server" Visible="false" CssClass="InfoLabel" EnableViewState="false" />
    <asp:Label ID="lblSendError" runat="server" Visible="false" CssClass="ErrorLabel"
        EnableViewState="false" />
    <table border="0" cellspacing="0" cellpadding="0" class="HeaderTable">
        <tr>
            <td class="FieldCaption">
                <asp:Label ID="lblFromCaption" runat="server" Text="From" EnableViewState="false"
                    displaycolon="true"></asp:Label>
            </td>
            <td class="Field">
                <asp:Label ID="lblFrom" runat="server" EnableViewState="false" />
                <%-- <cms:rtlfix islivesite="false" runat="server" id="rtlFix" />--%>
                <asp:TextBox ID="txtFrom" runat="server" Visible="false" CssClass="FromField" EnableViewState="false"
                    MaxLength="200" />
            </td>
        </tr>
        <tr>
            <td class="FieldCaption">
                <asp:Label ID="lblToCaption" runat="server" nableviewstate="false" displaycolon="true"
                    Text="To"></asp:Label>
            </td>
            <td class="Field">
                <asp:Label ID="lblTo" runat="server" EnableViewState="false" />
                <%--  <cms:messageuserselector id="ucMessageUserSelector" runat="server" visible="false"
                    enableviewstate="false" />--%>
            </td>
        </tr>
    </table>
    <div class="SubjectRow">
        <asp:Label ID="lblSubjectCaption" runat="server" CssClass="FieldCaption" EnableViewState="false"
            Text="subject" AssociatedControlID="txtSubject" displaycolon="true"></asp:Label>
        <br />
        <asp:TextBox ID="txtSubject" runat="server" CssClass="SubjectField" EnableViewState="false"
            MaxLength="200" />
    </div>
    <div class="Body">
        <asp:Label ID="lblText" runat="server" display="false" EnableViewState="false" Text="body"></asp:Label>
        <%-- <cms:bbeditor id="ucBBEditor" runat="server" enableviewstate="false" />--%>
    </div>
    <asp:Panel ID="pnlButtons" runat="server" CssClass="Buttons">
        <asp:Panel ID="pnlSubPanel" runat="server">
            <asp:Button ID="btnSendMessage" CssClass="SubmitButton" runat="server" EnableViewState="false" Text="send"
                OnClick="btnSendMessage_Click"></asp:Button>
            <asp:Button ID="btnClose" runat="server" CssClass="SubmitButton" Visible="false" Text="cancel"
                EnableViewState="false" OnClick="btnClose_Click"></asp:Button>
        </asp:Panel>
    </asp:Panel>
</asp:Panel>
<asp:Panel ID="pnlNoUser" runat="server" Visible="false" EnableViewState="false">
    <asp:Label ID="lblNoUser" CssClass="Info" runat="server" EnableViewState="false" />
</asp:Panel>
<asp:HiddenField ID="hdnUserId" runat="server" />

Open in new window

0
Comment
Question by:omegalove
  • 2
  • 2
4 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 33694044
try a diffrent id,

<uc1:uxSendMessage ID="uxSendMsg" Visible="true" runat="server" />

and use uxSendMsg in your page code
0
 

Author Comment

by:omegalove
ID: 33695771
still the same
Error      9      The name 'uxSendMsg' does not exist in the current context      C:\inetpub\wwwroot\PrivateMessaging\PrivateMessaging\Messaging\MyMessages\SendMessage.aspx.cs      42      13      PrivateMessaging
Error      10      The name 'uxSendMsg' does not exist in the current context      C:\inetpub\wwwroot\PrivateMessaging\PrivateMessaging\Messaging\MyMessages\SendMessage.aspx.cs      44      13      PrivateMessaging
Error      11      The name 'uxSendMsg' does not exist in the current context      C:\inetpub\wwwroot\PrivateMessaging\PrivateMessaging\Messaging\MyMessages\SendMessage.aspx.cs      45      13      PrivateMessaging
Error      12      The name 'uxSendMsg' does not exist in the current context      C:\inetpub\wwwroot\PrivateMessaging\PrivateMessaging\Messaging\MyMessages\SendMessage.aspx.cs      46      13      PrivateMessaging
Error      13      The name 'uxSendMsg' does not exist in the current context      C:\inetpub\wwwroot\PrivateMessaging\PrivateMessaging\Messaging\MyMessages\SendMessage.aspx.cs      47      13      PrivateMessaging
Error      14      The name 'uxSendMsg' does not exist in the current context      C:\inetpub\wwwroot\PrivateMessaging\PrivateMessaging\Messaging\MyMessages\SendMessage.aspx.cs      48      13      PrivateMessaging
Error      15      The name 'uxSendMsg' does not exist in the current context      C:\inetpub\wwwroot\PrivateMessaging\PrivateMessaging\Messaging\MyMessages\SendMessage.aspx.cs      49      13      PrivateMessaging
0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 33695966
is this correct???

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SendMessage.aspx.cs" Inherits="PrivateMessaging.Messaging.MyMessages.SendMessage" %>

check all your namespaces...

0
 

Author Closing Comment

by:omegalove
ID: 33696269
awesome
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
performance issue in asp web 5 37
imap mails 1 25
Obtain cell value using column ID in DataGrid using VB.NET 2 25
transaction in asp.net, sql server 6 43
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question