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: 20 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:













ui versus business layer\dataaccess layer development

a server side relative url required. what does that mean ??

what is difference in c# & vb.net generated msil?

prefixing url address

want to create knowledgebase web application using asp.net 1.1

print button

how to use sqldatasource.delete() command

iis

how can i do to send a simple email in html?????

can i discuss how to use dotnet framework here?

ajax editor extension

convert code behind to inline code

page control

on table load

heeellllllpppppppp

are objects shared across multiple sessions?

arithmetic operation resulted in an overflow error

datetime.now.month

web form design.

insert record into access with visual basic.

quotes inside if quotes

dropdownlistbinding

profile object questions

automation server cannot create object

detecting user's local privilleges

trying to access value from main page in a pop up form.

cdo configuration

directory events

what is happening here?

how can i call a page that uses only code or activate code directly from a menu click event ?

how do you link your asp file to a database that you create at the web hosting end?

filter

inheriting forms with a user control on it

please help w/ .js error

class file compilation during development

creating folders on the web server

using an if statement to pick which file to include

how can i run a program at the background in the server?

cookies not working

writing files to disk

conversion from string "" to type 'date' is not valid.

calendar problem

was asked this during an interview...

variable scope problem

how to put asp.net variables in html code

how to write javascript in vb.net?

need idea for a fairly simple problem

how to show today record?

text with gaps?how ?

why has asp.net appeared as an account holder on my computer?

   
  Privacy | Contact Us
All Times Are GMT