?
Solved

Cannot access the user control in aspx page.

Posted on 2010-09-16
4
Medium Priority
?
995 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 61

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 61

Accepted Solution

by:
HainKurt earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Integration Management Part 2
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…
Suggested Courses

609 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