Call

Category Archives: ASP.NET

VB.NET Code Snippets: Updating a data source using an event

0
Filed under ASP.NET, Microsoft

You may wish to update a data source using an event.

'You need to use FindControl to access control on a  FormView:
Dim FirstName As TextBox = FormView1.FindControl("FirstNameTextBox")
Dim LastName As TextBox = FormView1.FindControl("LastNameTextBox")
Dim Phone As TextBox = FormView1.FindControl("PhoneTextBox")
Dim Email As TextBox = FormView1.FindControl("EmailTextBox")
SqlDataSource1.InsertParameters("FirstName").DefaultValue = FirstName
SqlDataSource1.InsertParameters("LastName").DefaultValue = LastName
SqlDataSource1.InsertParameters("Phone").DefaultValue = Phone
SqlDataSource1.InsertParameters("Email").DefaultValue = Email
SqlDataSource1.Insert()

And, this is the code for Update:

SqlDataSource1.UpdateParameters("FirstName").DefaultValue = FirstName
SqlDataSource1.UpdateParameters("LastName").DefaultValue = LastName
SqlDataSource1.UpdateParameters("Phone").DefaultValue = Phone
SqlDataSource1.UpdateParameters("Email").DefaultValue = Email
SqlDataSource1. Update()

VB.NET: Retrieving Active Directory account properties

0
Filed under ASP.NET, Microsoft

The .NET Framework includes an API called System.DirectoryServices. The sample VB.NET code below shows how to retrieve user account properties from the Active Directory.

In order to use System.DirectoryServices classes, you will need to first add a reference to System.DirectoryServices.

Imports System.DirectoryServices is required at the very top of your VB.NET code.

Function GetUserProperties(ByVal GetUser, ByVal Result)
        Dim objSearch As New DirectorySearcher
        objSearch.SearchRoot = New DirectoryEntry("LDAP://dc=domain,dc=co,dc=uk")
        objSearch.Filter = GetUser
        'cn = Full Name, givenName = First name, initials = Middle names, sn = Surname, mail = email address
        objSearch.PropertiesToLoad.AddRange(New String() {"cn", "giveName", "initials", "sn", "department", "mail", "Manager"})
        Dim objResult As SearchResult
        objResult = objSearch.FindOne()
        GetUserProperties = (objResult.Properties(Result)(0))
End Function

Replace dc=domain, dc=co, dc=uk with your AD settings.

Free SharePoint Developement Training from Microsoft

0
Filed under ASP.NET, Microsoft, SharePoint

Module 1: SharePoint Development for .Net Developers

Module 2: Web Parts

Module 3: Page Navigation

Module 4: Page Branding

Module 5: Data List

Module 6: Web Services

Module 7: Event Handlers

Module 8: Content Types and Site Columns

Module 9: Workflow

Module 10: User Management

Module 11: Silverlight

Module 12: Deployment

ASP.NET: Deploying an AJAX enabled application to SharePoint

0
Filed under ASP.NET, Microsoft, SharePoint

You may develop a web application that uses the ASP.NET AJAX Control Toolkit (http://www.asp.net/ajax/AjaxControlToolkit/Samples), if you plan to deploy this application to a SharePoint Server, you will need to complete the following steps:Copy the AjaxControlToolkit.dll to the BIN folder of the SharePoint server.

  1. Copy the AjaxControlToolkit.dll to the BIN folder of the SharePoint server.
  2. Edit the web.config file as below:
<SafeControls>
      <SafeControl Assembly="System.Web.Extensions, Version=3.5.0.0,     Culture=neutral, PublicKeyToken=31bf3856ad364e35"     Namespace="System.Web.UI" TypeName="*" Safe="True" />
</SafeControls>

<configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
          <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
</configSections> 

<pages>
  <controls>
    <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </controls>
</pages>

<assemblies>
       <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>

<httpHandlers>
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>

<httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>