Microsoft Content Management Server - Using base.PerformActionBehavior();

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > February 2007 > Using base.PerformActionBehavior();





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Using base.PerformActionBehavior();
Tom

2007-02-12, 1:24 am

I have a class file that is tied to a custom action for the CMS Console.

When my users Edit any page in the site and then click the Save & Exit
button a new link shows up in the console (my custom action) called Send
Email/Submit.
So when my uses click this link, a new web page appears with users in a
dropdown list box. My users pick the user from the dropdown that they wish
to send the email to and press submit. The user's email is appended to the
CMS query string Example: chan="m2@myaddress.com"

And the code below is executed.

HOWEVER! While the email piece is working just fine, the Using
base.PerformActionBehavior(); line is not being executed. I know this
because the page status does not change from Saved to Waiting approval. I
was under the impression that if my class inhereited from Submit Action that
this line Using base.PerformActionBehavior(); would do the submitting for
me.


Can someone help me out here?

NOTE: My submitEmail class is dervied from SubmitAction as follows.

public class SubmitEmail : SubmitAction


Many thanks in advance.

Tom

Here is the code
try
{

sQuery = this.Page.Request.QueryString.Get("chan").ToString();
if (sQuery.Length > 10)
{

iPos = sQuery.IndexOf("^d");
sEmailName = sQuery.Substring(0, iPos);

CmsHttpContext cmsContext = CmsHttpContext.Current;
Posting P = cmsContext.Posting;
sUrl = P.Url;
sUrl =
ConfigurationManager.AppSettings["ServerName"].ToString() + sUrl;


sBody = "<A href=" + sUrl + ">Please approve this
document</a><br>";
sSubject = "A CMS Posting requires your approval";
System.Net.Mail.MailMessage message = new
System.Net.Mail.MailMessage(ConfigurationManager.AppSettings["EMailFromAddress"].ToString(), sEmailName, sSubject, sBody);
System.Net.Mail.SmtpClient mailClient = new
System.Net.Mail.SmtpClient(ConfigurationManager.AppSettings["EmailServerName"].ToString());
message.IsBodyHtml = true;
mailClient.UseDefaultCredentials = true;
mailClient.Send(message);
cmsContext = null;

base.PerformActionBehavior();
this.Page.Response.Redirect(P.UrlModeUnpublished,true);
}
}
catch(Exception ex)
{
throw (ex);
}




Stefan Goßner [MSFT]

2007-02-12, 7:18 am

Hi Tom,

base.PerformActionbehavior will do exactly this.
You did not post the complete code. Does your code live in the
PerformActionBehavior class or somewhere else?

Cheers,
Stefan

"Tom" <Tom@discussions.microsoft.com> wrote in message
news:7B5BC033-A4E5-4B04-BCD0-E8DFA8820D9A@microsoft.com...
>I have a class file that is tied to a custom action for the CMS Console.
>
> When my users Edit any page in the site and then click the Save & Exit
> button a new link shows up in the console (my custom action) called Send
> Email/Submit.
> So when my uses click this link, a new web page appears with users in a
> dropdown list box. My users pick the user from the dropdown that they
> wish
> to send the email to and press submit. The user's email is appended to
> the
> CMS query string Example: chan="m2@myaddress.com"
>
> And the code below is executed.
>
> HOWEVER! While the email piece is working just fine, the Using
> base.PerformActionBehavior(); line is not being executed. I know this
> because the page status does not change from Saved to Waiting approval. I
> was under the impression that if my class inhereited from Submit Action
> that
> this line Using base.PerformActionBehavior(); would do the submitting
> for
> me.
>
>
> Can someone help me out here?
>
> NOTE: My submitEmail class is dervied from SubmitAction as follows.
>
> public class SubmitEmail : SubmitAction
>
>
> Many thanks in advance.
>
> Tom
>
> Here is the code
> try
> {
>
> sQuery = this.Page.Request.QueryString.Get("chan").ToString();
> if (sQuery.Length > 10)
> {
>
> iPos = sQuery.IndexOf("^d");
> sEmailName = sQuery.Substring(0, iPos);
>
> CmsHttpContext cmsContext = CmsHttpContext.Current;
> Posting P = cmsContext.Posting;
> sUrl = P.Url;
> sUrl =
> ConfigurationManager.AppSettings["ServerName"].ToString() + sUrl;
>
>
> sBody = "<A href=" + sUrl + ">Please approve this
> document</a><br>";
> sSubject = "A CMS Posting requires your approval";
> System.Net.Mail.MailMessage message = new
> System.Net.Mail.MailMessage(ConfigurationManager.AppSettings["EMailFromAddress"].ToString(),
> sEmailName, sSubject, sBody);
> System.Net.Mail.SmtpClient mailClient = new
> System.Net.Mail.SmtpClient(ConfigurationManager.AppSettings["EmailServerName"].ToString());
> message.IsBodyHtml = true;
> mailClient.UseDefaultCredentials = true;
> mailClient.Send(message);
> cmsContext = null;
>
> base.PerformActionBehavior();
> this.Page.Response.Redirect(P.UrlModeUnpublished,true);
> }
> }
> catch(Exception ex)
> {
> throw (ex);
> }
>
>
>
>



Tom

2007-02-12, 7:18 am

Stefan:

Thanks for helping out here.
Uh, I'm not sure I understand your response.

My code does not live in the base.PerformActionBehavior(); I thought if I
inherited from SubmitAction that I could just call the Re: Using
base.PerformActionBehavior() method. My code all lives in this method of my
SubmitEmail class.

Can you be more specific and possibly send me an example of how I might
accomplish the right solution?

Thanks

Tom



"Stefan Goßner [MSFT]" wrote:

> Hi Tom,
>
> base.PerformActionbehavior will do exactly this.
> You did not post the complete code. Does your code live in the
> PerformActionBehavior class or somewhere else?
>
> Cheers,
> Stefan
>
> "Tom" <Tom@discussions.microsoft.com> wrote in message
> news:7B5BC033-A4E5-4B04-BCD0-E8DFA8820D9A@microsoft.com...
>
>
>

Stefan Goßner [MSFT]

2007-02-12, 7:18 am

Hi Tom,

you need to call this method from the PerformActionBehavior method of your
class - not from any other method.

Cheers,
Stefan


"Tom" <Tom@discussions.microsoft.com> wrote in message
news:58EAB703-C8AC-470D-90CE-02743440D2DC@microsoft.com...[vbcol=seagreen]
> Stefan:
>
> Thanks for helping out here.
> Uh, I'm not sure I understand your response.
>
> My code does not live in the base.PerformActionBehavior(); I thought if
> I
> inherited from SubmitAction that I could just call the Re: Using
> base.PerformActionBehavior() method. My code all lives in this method of
> my
> SubmitEmail class.
>
> Can you be more specific and possibly send me an example of how I might
> accomplish the right solution?
>
> Thanks
>
> Tom
>
>
>
> "Stefan Goßner [MSFT]" wrote:
>


Tom

2007-02-12, 1:16 pm

Stefan:

Can you please provide me an example of how I would call the
base.PerformActionbehavior class?

Thanks

Tom


"Stefan Goßner [MSFT]" wrote:

> Hi Tom,
>
> you need to call this method from the PerformActionBehavior method of your
> class - not from any other method.
>
> Cheers,
> Stefan
>
>
> "Tom" <Tom@discussions.microsoft.com> wrote in message
> news:58EAB703-C8AC-470D-90CE-02743440D2DC@microsoft.com...
>
>
>

Tom

2007-02-12, 1:16 pm

Stefan:

I tried changing my code to this but it still does not change the posting
status to "Waiting approval"

I added this code to my class.
protected override void PerformActionBehavior()
{
base.PerformActionBehavior();
}

And instead of calling base.PerformActionBehavior(); in my custom method I
now call
PerformActionBehavior();

After recompiling and testing it out, I get the email but the page status
does not change.

Please help!

Thanks

Tom

"Stefan Goßner [MSFT]" wrote:

> Hi Tom,
>
> you need to call this method from the PerformActionBehavior method of your
> class - not from any other method.
>
> Cheers,
> Stefan
>
>
> "Tom" <Tom@discussions.microsoft.com> wrote in message
> news:58EAB703-C8AC-470D-90CE-02743440D2DC@microsoft.com...
>
>
>

Stefan Goßner [MSFT]

2007-02-12, 1:16 pm

Hi Tom,

something like this:

public class MySubmitAction : SubmitAction
{
...

protected override void PerformActionBehavior()
{
...
base.PerformActionBehavior();
}

...

}


Cheers,
Stefan


"Tom" <Tom@discussions.microsoft.com> wrote in message
news:A0FD59C3-4A57-44BE-B5EC-7D694E2EB2E6@microsoft.com...[vbcol=seagreen]
> Stefan:
>
> Can you please provide me an example of how I would call the
> base.PerformActionbehavior class?
>
> Thanks
>
> Tom
>
>
> "Stefan Goßner [MSFT]" wrote:
>


Stefan Goßner [MSFT]

2007-02-12, 1:16 pm

Hi Tom,

stop calling PerformActionBehavior!
That is not necessary.

Cheers,
Stefan


"Tom" <Tom@discussions.microsoft.com> wrote in message
news:844CD618-ECEF-49CF-85AE-3AFE75F9A5C1@microsoft.com...[vbcol=seagreen]
> Stefan:
>
> I tried changing my code to this but it still does not change the posting
> status to "Waiting approval"
>
> I added this code to my class.
> protected override void PerformActionBehavior()
> {
> base.PerformActionBehavior();
> }
>
> And instead of calling base.PerformActionBehavior(); in my custom method
> I
> now call
> PerformActionBehavior();
>
> After recompiling and testing it out, I get the email but the page status
> does not change.
>
> Please help!
>
> Thanks
>
> Tom
>
> "Stefan Goßner [MSFT]" wrote:
>


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com