You can create different types of ASP.net projects in Visual Studio 2010 , they are :
- Web Sites
- Web Applications
- Web Services
- AJAX Server
Abstract class can contain non abstract method. When we want that all subclass must implement all methods of base class ;In such situation use interface.In other hand when we want only some method of base class in our subclass then use base class as abstract class because abstract class can contain non-abstract method.
Interface: –> If your child classes should all implement a certain group of methods/functionalities but each of the child classes is free to provide its own implementation then use interfaces. For e.g. if you are implementing a class hierarchy for vehicles implement an interface called Vehicle which has properties like Colour MaxSpeed etc. and methods like Drive(). All child classes like Car Scooter AirPlane SolarCar etc. should derive from this base interface but provide a seperate implementation of the methods and properties exposed by Vehicle. –> If you want your child classes to implement multiple unrelated functionalities in short multiple inheritance use interfaces. For e.g. if you are implementing a class called SpaceShip that has to have functionalities from a Vehicle as well as that from a UFO then make both Vehicle and UFO as interfaces and then create a class SpaceShip that implements both Vehicle and UFO . Abstract Classes –> When you have a requirement where your base class should provide default implementation of certain methods whereas other methods should be open to being overridden by child classes use abstract classes. For e.g. again take the example of the Vehicle class above. If we want all classes deriving from Vehicle to implement the Drive() method in a fixed way whereas the other methods can be overridden by child classes. In such a scenario we implement the Vehicle class as an abstract class with an implementation of Drive while leave the other methods / properties as abstract so they could be overridden by child classes. –> The purpose of an abstract class is to provide a common definition of a base class that multiple derived classes can share. For example a class library may define an abstract class that is used as a parameter to many of its functions and require programmers using that library to provide their own implementation of the class by creating a derived class. Use an abstract class * When creating a class library which will be widely distributed or reused—especially to clients, use an abstract class in preference to an interface; because, it simplifies versioning. This is the practice used by the Microsoft team which developed the Base Class Library. ( COM was designed around interfaces.) * Use an abstract class to define a common base class for a family of types. * Use an abstract class to provide default behavior. * Subclass only a base class in a hierarchy to which the class logically belongs. Use an interface * When creating a standalone project which can be changed at will, use an interface in preference to an abstract class; because, it offers more design flexibility. * Use interfaces to introduce polymorphic behavior without subclassing and to model multiple inheritance—allowing a specific type to support numerous behaviors. * Use an interface to design a polymorphic hierarchy for value types. * Use an interface when an immutable contract is really intended. * A well-designed interface defines a very specific range of functionality. Split up interfaces that contain unrelated functionality. |
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim totalSize As Double 'to store total size of the attachments
Dim FileName As String 'path for the temp folder
Dim strBody As String
Dim strUname As String
Dim i As Integer
totalSize = 0
strBody = "The attached files are placed in the below location" & vbCrLf
i = 1
strUname = Environ("USERNAME")
If Item.Attachments.Count <> 0 Then 'Check if files are attached
For Each At In Item.Attachments
totalSize = totalSize + At.Size
Next At
'Check the total size of attached files are greater than 1MB
If totalSize >= 10 Then
For Each Atmt In Item.Attachments
strBody = strBody & "http://mysite/personal/" & strUname & "/Personal%20Documents/" & Atmt & vbCrLf
FileName = "C:\Users\" & strUname & "\AppData\Local\Temp\" & Trim(Atmt.FileName)
Atmt.SaveAsFile FileName 'Save the attachments to Temp folder of your system
UploadFile "C:\Users\" & strUname & "\AppData\Local\Temp\" & Atmt, "http://mysite/personal/" & strUname, "Personal Documents/" & Atmt.FileName, "Test title", "Test checkin comment"
Next Atmt
End If
For i = 1 To Item.Attachments.Count 'Delete Attached files in mail
Item.Attachments(1).Delete
Next i
Item.Body = Item.Body & strBody
'MsgBox ("Total Size:" & totalSize & "KB")
MsgBox "Done"
End If
End Sub
Function StringToByteArray(str)
Set stream = CreateObject("ADODB.Stream")
stream.Open
stream.Type = 2 ''adTypeText
stream.Charset = "ascii"
stream.WriteText str
stream.Position = 0
stream.Type = 1 ''adTypeBinary
StringToByteArray = stream.Read()
stream.Close
End Function
Sub UploadFile(sourcePath, siteUrl, docName, title, checkincomment)
strHeader = "method=put+document%3a12.0.4518.1016" + "&service_name=%2f" + "&document=[document_name=" + docName + ";meta_info=[vti_title%3bSW%7c" + title + "]]" + "&put_option=overwrite,createdir,migrationsemantics" + "&comment=" + "&keep%5fchecked%5fout=false" + vbLf
byteArray = StringToByteArray(strHeader)
Set stream = CreateObject("ADODB.Stream")
stream.Open
stream.Type = 1 ''adTypeBinary
stream.Write byteArray
Set stream2 = CreateObject("ADODB.Stream")
stream2.Open
stream2.Type = 1 ''adTypeBinary
stream2.LoadFromFile sourcePath
stream2.CopyTo stream, -1
stream.Position = 0
Set xmlHttp = CreateObject("MSXML2.XMLHTTP")
xmlHttp.Open "POST", siteUrl + "/_vti_bin/_vti_aut/author.dll", False
xmlHttp.setRequestHeader "Content-Type", "application/x-vermeer-urlencoded"
xmlHttp.setRequestHeader "X-Vermeer-Content-Type", "application/x-vermeer-urlencoded"
xmlHttp.setRequestHeader "User-Agent", "FrontPage"
xmlHttp.Send stream
If xmlHttp.Status = 200 Then
If InStr(xmlHttp.responseText, "successfully") = 0 Then
MsgBox "ERROR:" & vbCrLf & xmlHttp.responseText
Else
''Checkin
strHeader = "method=checkin+document%3a12.0.4518.1016" + "&service_name=%2f" + "&document_name=" & docName + "&comment=" + checkincomment + "&keep%5fchecked%5fout=false" + vbLf
Set xmlHttp = CreateObject("MSXML2.XMLHTTP")
xmlHttp.Open "POST", siteUrl + "/_vti_bin/_vti_aut/author.dll", False
xmlHttp.setRequestHeader "Content-Type", "application/x-vermeer-urlencoded"
xmlHttp.setRequestHeader "X-Vermeer-Content-Type", "application/x-vermeer-urlencoded"
xmlHttp.setRequestHeader "User-Agent", "FrontPage"
xmlHttp.Send strHeader
End If
End If
If xmlHttp.Status / 100 <> 2 Then
MsgBox "ERROR: status = " & xmlHttp.Status & vbCrLf & xmlHttp.responseText
End If
End Sub
Function UserNameWindows() As String
Dim UserName As String
UserName = Environ("USERNAME")
'return UserName
End Function
When a user does this | The item is | The item can be restored by |
---|---|---|
Deletes an item | Held in the first-stage Recycle Bin until the item is deleted from the Recycle Bin or the item has been in the Recycle Bin longer than the time limit configured for an item to be held in the Recycle Bin. | Users or site collection administrators |
Deletes an item from the Recycle Bin | Held in the second-stage Recycle Bin | Site collection administrators |
Name | Description | |
---|---|---|
OpenWeb() | Returns the Web site that is associated with the URL that is used in an SPSite constructor. | |
OpenWeb(Guid) | Returns the Web site with the specified GUID. | |
OpenWeb(String) | Returns the Web site that is located at the specified server-relative or site-relative URL. | |
OpenWeb(String, Boolean) | Returns the Web site that is located at the specified server-relative or site-relative URL based on a Boolean value that specifies whether the exact URL must be supplied. |
protected override void OnPreRender(EventArgs e) { EnsureChildControls(); if (_myProvider != null) { myLabel.Text = _myProvider.TextBoxString; } }
protected override void CreateChildControls() { Controls.Clear(); myLabel = new Label(); myLabel.Text = "Default text"; Controls.Add(myLabel); }
[ConnectionConsumer("String Consumer", "StringConsumer")] public void TextBoxStringConsumer(ITextBoxString Provider) { _myProvider = Provider; }