Vb Event handling in a control?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Microsoft Content Management Server > Vb Event handling in a control?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Vb Event handling in a control?  
BrettG


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-30-04 04:43 PM

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.Create_Posting);
}
else
{
Microsoft.ContentManagement.WebControls.WebAuthorContext.Current.SavePosting
Event
+= new Microsoft.ContentManagement.WebControls.WebAuthorPostingEventHandler(
this.Save_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 ]



    Re: Vb Event handling in a control?  
Stefan [MSFT]


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
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 ]



    Sponsored Links  




 





   All times are GMT. The time now is 05:15 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register