Mono Support Can I override the 'MessageCreate' web part? (Closed)

Viewed 23600 time(s), 6 post(s), 7/21/2011 8:34:56 AM - by inanc
7/21/2011 8:34:56 AM
469 Reputation 60 Total posts

Hi,
I wonder if I can override the MessageCreate webpart? Let me further explain;
Forexample, I would like to send a private message to a specific user that I already know. Let's say to user Anne.
And I would like to put subject to subject TextBox on pageload event forexample. Please find my example page below.

ASPX part
--------------
<%@ Register TagPrefix="MonoX" TagName="MessageCreate" Src="/MonoX/ModuleGallery/SocialNetworking/Messaging/MessageCreate.ascx" %>
<MonoX:MessageCreate runat="server" ID="messageCreate" Title="New message" />


CodeBehind
-------------------
messageCreate.Title = "Yeni mesaj";
messageCreate.AllowFileUpload = false;


In that example I can override the title and AllowFileUpload . I wonder it it is possible to override the MonoX:MessageCreate for the Subject and Message properties? Thank you..
Inanc

1
7/21/2011 11:37:20 AM
1871 Reputation 252 Total posts

If i was you.. I would try making my own class web part and inheriting

ModuleGallery.SocialNetworking.Messaging

Then once you do that.. you should be able to override that MessageCreate function.

Then use your own webpart class to send your messages.

2
7/21/2011 12:41:28 PM
7207 Reputation 956 Total posts

Yes it is possible. As Shawn said, create a new Web part, copy the content of the MessageCreate.ascx in it (change the CodeBehind and Inherits attributes in the first line to reflect your settings and Web part name), and in the codebehind say that your Web part inherits from MonoSoftware.MonoX.ModuleGallery.SocialNetworking.MessageCreate You can than override the OnLoad (or any other) event in it, call the base.OnLoad and do your stuff before or after that.
Note that you will have to change the MessageCenter.ascx also if you want to use the changed MessageCreate part in a standard scenario, as it is its container control. Inseat of the original MonoX MessageCreate you would have to reference your changed Web part.

3
7/21/2011 12:45:58 PM
3016 Reputation 428 Total posts

Hi,

you can use shawndg's approach, below are more detailed steps:

1. Add a new user control with code behind which needs to extend the Message Create Module:

namespace YourNamespace
{
    public partial class CustomMessageCreate : MonoSoftware.MonoX.ModuleGallery.SocialNetworking.MessageCreate
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            txtSubject.Text = "Custom subject";
        }
        
    }
}

2. Markup: copy the markup from MonoX MessageCreate module to your custom module and make some changes:

from:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MessageCreate.ascx.cs" Inherits="MonoSoftware.MonoX.ModuleGallery.SocialNetworking.MessageCreate" %>

to:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CustomMessageCreate.ascx.cs" Inherits="YourNamespace.CustomMessageCreate" %>

PS: do not forget to replace the test "YourNamespace" namespace with the one you use.

Regards.

4
7/21/2011 1:27:27 PM
469 Reputation 60 Total posts

Ok,
I'll try it. Thank everyone for answers..

Kind Regards

5
7/21/2011 1:57:40 PM
469 Reputation 60 Total posts

Ha ha ha!
I love Monox! Great!
Thank you for the helps!
Thank you imarusic

Inanc

6
This is a demo site for MonoX. Please visit Mono Software for more info.