CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > general_asp.net.getting_started Tags:
Item Type: Date Entered: 10/12/2006 7:57:22 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 1 Views: 16 Favorited: 0 Favorite
2 Items, 1 Pages 1 |< << Go >> >|
"shapper" <>
NewsGroup User
Default Value10/12/2006 7:57:22 PM

0

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
"Lee Dumond" <>
NewsGroup User
Re: Default Value10/12/2006 10:49:02 PM

0

You would have to set up your default values when you declare the fields, as follows: 

Imports Microsoft.VisualBasic

Imports System.Net.Mail

Public Class MailClass

Private _attachmentCollection As AttachmentCollection

Private _toCollection As MailAddressCollection = GetDefaultToCollection()

Private _bccCollection As MailAddressCollection

Private _from As MailAddress = New MailAddress(System.Configuration.ConfigurationManager.AppSettings("myFromAddress"))

Public Property AttachmentCollection() As AttachmentCollection

Get

Return _attachmentCollection

End Get

Set(ByVal value As AttachmentCollection)

_attachmentCollection = value

End Set

End Property

Public Property ToCollection() As MailAddressCollection

Get

Return _toCollection

End Get

Set(ByVal value As MailAddressCollection)

_toCollection = value

End Set

End Property

Public Property BccCollection() As MailAddressCollection

Get

Return _bccCollection

End Get

Set(ByVal value As MailAddressCollection)

_bccCollection = value

End Set

End Property

Public Property From() As MailAddress

Get

Return _from

End Get

Set(ByVal value As MailAddress)

_from = value

End Set

End Property

Private Function GetDefaultToCollection() As MailAddressCollection

Dim theCollection As New MailAddressCollection

theCollection.Add(System.Configuration.ConfigurationManager.AppSettings("myDefaultAddress"))

Return theCollection

End Function

End Class


==================================================
Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we all know you have been helped.
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:













is there a way to execute class every xx minute?

split function and working with arrays

cassini web server

detecting errors...

session variable, need help!!

datetime -- > problem in converting textbox value into datetime variable

i want application 'a' to run within another sites html page

configurationsettings

display a list of hyperlinks

tooltip with "more" tab

can asp and asp.net be onthe same web server ?

how to write my asp.net blog?

embedded excel

mfc in .net ??

unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.

what happens when session expires?

help with encrypt and decrypt

getting a datalist to work

consume web service help

sorting dataset

server.transfer in criticism of the asp.net 2.0 compilation model

click and drag functionallity - webapp

using pre-compilation with a deployment project.

help w/ appl. architecture--plzzzzz

response object problem

sql next to max record?

how to import namespace

just getting started, a few questions

pass two values in querystring

custom namespaces with asp.net = too much hassle?

how to do encript and decript?

[2005] aspx sending email [doesnt sent to hotmail] ??

using vs 2005 to work on asp.net 1.1 site?

asp>net blogging software

shared method or non shared method

calling pages multiple times

framework reversion nightmare

stupid error, # appends to qs

ms web matrix problem

compatibility

build asp.net 2.0 application in release mode

backporting from asp.net 2 to asp.net 1?

click event on button

need forum code

how to create blog?

add windows account to webserver

declaring variables question

label tag and its value?

uploading and downloading documents

problems in populating treeview

   
  Privacy | Contact Us
All Times Are GMT