MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

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

Viewed 13965 time(s), 6 post(s) 7/21/2011 8:34:56 AMby inanc

Related topics

inanc

inanc

7/21/2011 8:34:56 AM
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

This content has not been rated yet. 
469 Reputation 60 Total posts
shawndg

shawndg

7/21/2011 11:37:20 AM
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.
This content has not been rated yet. 
1871 Reputation 252 Total posts
denis

denis

7/21/2011 12:41:28 PM
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.
This content has not been rated yet. 
7207 Reputation 956 Total posts
imarusic

imarusic

7/21/2011 12:45:58 PM
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.
Rated 5.00, 1 vote(s). 
3016 Reputation 428 Total posts
inanc

inanc

7/21/2011 1:27:27 PM
Ok,
I'll try it. Thank everyone for answers..

Kind Regards
This content has not been rated yet. 
469 Reputation 60 Total posts
inanc

inanc

7/21/2011 1:57:40 PM
Ha ha ha!
I love Monox! Great!
Thank you for the helps!
Thank you imarusic

Inanc
This content has not been rated yet. 
469 Reputation 60 Total posts