Default value

Discussion in 'ASP .Net' started by shapper, Oct 12, 2006.

  1. shapper

    shapper Guest

    Hello,

    I am creating a class where I have various properties.
    I was able to set default values for most properties which have common
    types.

    However, I am 3 properties which I don't know how to create the default
    value:

    1. Mail.AttachmentCollection
    I want to make it empty. But I am not sure I can do this.

    Private _AttachmentCollection As Mail.AttachmentCollection
    <DefaultValue("")> _
    Public Property AttachmentCollection() As Mail.AttachmentCollection
    ...

    2. Mail.MailAddressCollection
    I want to create the default collection with only one MailAddress.
    The one which is available in my Web.Config file under:
    <system.net>
    <mailSettings>
    <smtp
    deliveryMethod = "network"
    from = "atelier@jaquelineroxoatelier">
    ...

    Private _ToCollection As Mail.MailAddressCollection
    <DefaultValue("")> _
    Public Property ToCollection() As Mail.MailAddressCollection
    ...

    3. Mail.MailAddressCollection
    I want this email colection to be empty. Similar to one. It is just
    a different collection type.

    Private _BccCollection As Mail.MailAddressCollection
    <DefaultValue("")> _
    Public Property BccCollection() As Mail.MailAddressCollection

    4. Mail.MailAddress
    I want to create this MailAddress with the datain my Web.Config.
    Similar to 2. It is just a MailAddress instead of a Collection.

    ' From
    Private _From As Mail.MailAddress
    Public Property From() As Mail.MailAddress
    ...

    Could someone help me out with this?

    Thanks,
    Miguel
    shapper, Oct 12, 2006
    #1
    1. Advertising

  2. > 1. Mail.AttachmentCollection
    > I want to make it empty. But I am not sure I can do this.


    Mail.AttachmentCollection.Clear()

    > 2. Mail.MailAddressCollection
    > I want to create the default collection with only one MailAddress.


    Ask SmtpSection to give the appropriate details.
    Clear the collection and then add one entry.

    > 3. Mail.MailAddressCollection
    > I want this email colection to be empty. Similar to one. It is just
    > a different collection type.


    Collections are always 'Clear'-able.

    > 4. Mail.MailAddress


    Again, talk to SmtpSection


    SmtpSection is in namespace System.Net.Configuration in System.dll

    An example:

    SmtpSection smtpSettings = (SmtpSection)
    ConfigurationManager.GetSection("system.net/mailSettings/smtp",
    typeof(SmtpSection));

    string from = smtpSettings.From;


    --
    Happy Hacking,
    Gaurav Vaish | www.mastergaurav.com
    www.edujinionline.com
    http://eduzine.edujinionline.com
    -----------------------------------------
    Gaurav Vaish \(www.EdujiniOnline.com\), Oct 13, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. micky

    default.mspx or default.do

    micky, Dec 16, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    478
    Andrew Robinson
    Dec 17, 2005
  2. Gaetan
    Replies:
    3
    Views:
    1,410
    Juan T. Llibre
    Feb 14, 2006
  3. Michael Ahlers
    Replies:
    1
    Views:
    5,641
    Martin Honnen
    Jul 12, 2004
  4. C Gillespie
    Replies:
    3
    Views:
    396
    Peter Hansen
    Mar 22, 2005
  5. LaundroMat
    Replies:
    50
    Views:
    947
    Hendrik van Rooyen
    Oct 14, 2006
Loading...

Share This Page