03-30-04 04:43 PM
Hi Brett,
the values from your text boxes are available in the global.asax by reading
the relevant request.form fields.
Cheers,
Stefan.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"BrettG" <brettgarnier@yahoo.com> wrote in message
news:aded4e5e.0403300800.31b262c2@posting.google.com...
> Hi,
>
> I had previously built a very simple web user control in C# and I'm
> trying to port it to vb.net. The control was basically two textboxes
> for meta keywords and meta description, the values are saved to custom
> properties and rendered when published as meta tags.
>
> I'd been getting the values of the textboxes during the _TextChanged
> events and setting class level string variables to their values.
> Example:
> --------------------------------------------------------
> private void txtMetaDescription_TextChanged(object sender,
> System.EventArgs e)
> {
> _sDescription = txtMetaDescription.Text;
> }
>
> Then I had added event handlers for save/create events in OnInit:
> Example:
> --------------------------------------------------------
> WebAuthorContext editState = WebAuthorContext.Current;
>
> if(editState.Mode == WebAuthorContextMode.AuthoringNew ||
> editState.Mode == WebAuthorContextMode.AuthoringReedit )
> {
> this.Visible = true;
> if (editState.Mode == WebAuthorContextMode.AuthoringNew)
> {
>
Microsoft.ContentManagement.WebControls.WebAuthorContext.Current.CreatedPost
ingEvent
> += new
Microsoft.ContentManagement.WebControls.WebAuthorPostingEventHandler(this.Cr
eate_Posting);
> }
> else
> {
>
Microsoft.ContentManagement.WebControls.WebAuthorContext.Current.SavePosting
Event
> += new
Microsoft.ContentManagement.WebControls.WebAuthorPostingEventHandler(this.Sa
ve_Posting);
> }
> }
> else
> {
> this.Visible = false;
> }
>
>
> Lastly the actual value setting was in my event handlers:
> Example:
> --------------------------------------------------------
> private void Save_Posting(object sender,
> Microsoft.ContentManagement.WebControls.WebAuthorPostingEventArgs
> args)
> {
> if (_sDescription != string.Empty)
> CmsUtil.CustomCmsProperties.SavePostingProperty(_sDescription,
> "MetaDescription",args.Posting);
> if ( _sKeywords != string.Empty)
> CmsUtil.CustomCmsProperties.SavePostingProperty(_sKeywords,
> "MetaKeywords",args.Posting);
> }
>
//--------------------------------------------------------------------------
--------
>
>
> I've seen examples that show how to put event handlers in global.asax,
> but is there a way that I can add this into my control? Is there a way
> that I can add this to global.asax and still get the values from my
> textboxes without having to use session?
>
> Any advice would be much appreciated, I'm sure that I can come up with
> a cludgy fix but if you have any suggestions I'd like to hear them.
>
> Thanks,
>
> Brett
[ Post a follow-up to this message ]
|