how to use WebPart in asp.net2.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • archu007
    New Member
    • May 2007
    • 28

    how to use WebPart in asp.net2.0

    Hi frds
    i hav used webparts in my application and i'm using sqlserver2000
    when i run the application the following error is displayed

    "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) "

    this is my html code:

    <legend>Simpl e WebPart Demo</legend>
    <asp:DropDownLi st ID="DropDownLis t1" runat="server" AutoPostBack="T rue" OnSelectedIndex Changed="DropDo wnList1_Selecte dIndexChanged">
    <asp:ListItem>B rowse</asp:ListItem>
    <asp:ListItem>D esign</asp:ListItem>
    </asp:DropDownLis t>&nbsp; Select design mode.You will be able to drag the calendar from the
    FirstWebPartZon e to the SecondWebPartZo ne.
    <asp:WebPartMan ager ID="WebPartMana ger1" runat="server">
    </asp:WebPartMana ger>
    <asp:WebPartZon e ID="FirstWebPar tZone" runat="server" Width="214px" EmptyZoneText=" Add a Web Part to this zone by dropping it here." EnableViewState ="False">
    <ZoneTemplate >
    <asp:Calendar ID="Calendar1" runat="server" BackColor="Whit e" BorderColor="#3 366CC"
    BorderWidth="1p x" CellPadding="1" DayNameFormat=" Shortest" Font-Names="Verdana"
    Font-Size="8pt" ForeColor="#003 399" Height="200px" Width="220px">
    <SelectedDaySty le BackColor="#009 999" Font-Bold="True" ForeColor="#CCF F99" />
    <TodayDayStyl e BackColor="#99C CCC" ForeColor="Whit e" />
    <SelectorStyl e BackColor="#99C CCC" ForeColor="#336 666" />
    <WeekendDayStyl e BackColor="#CCC CFF" />
    <OtherMonthDayS tyle ForeColor="#999 999" />
    <NextPrevStyl e Font-Size="8pt" ForeColor="#CCC CFF" />
    <DayHeaderSty le BackColor="#99C CCC" ForeColor="#336 666" Height="1px" />
    <TitleStyle BackColor="#003 399" BorderColor="#3 366CC" BorderWidth="1p x" Font-Bold="True"
    Font-Size="10pt" ForeColor="#CCC CFF" Height="25px" />
    </asp:Calendar>
    </ZoneTemplate>
    <CloseVerb Visible="False" />
    <MinimizeVerb Visible="False" />
    <RestoreVerb Visible="False" />
    </asp:WebPartZone >
    <asp:WebPartZon e ID="SecondWebPa rtZone" runat="server" EmptyZoneText=" Add a Web Part to this zone by dropping it here."
    EnableViewState ="False" Width="236px">
    <CloseVerb Visible="False" />
    <MinimizeVerb Visible="False" />
    <RestoreVerb Visible="False" />
    </asp:WebPartZone >

    this is the code in codebehind(vb):

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
    System.Threadin g.Thread.Curren tThread.Current Culture = New System.Globaliz ation.CultureIn fo("en-us")
    System.Threadin g.Thread.Curren tThread.Current UICulture = New System.Globaliz ation.CultureIn fo("en-us")
    End Sub
    Protected Sub DropDownList1_S electedIndexCha nged(ByVal sender As Object, ByVal e As System.EventArg s) Handles DropDownList1.S electedIndexCha nged
    Select Case Me.DropDownList 1.SelectedValue
    Case "Browse"
    Me.WebPartManag er1.DisplayMode = WebPartManager. BrowseDisplayMo de
    Case "Design"
    Me.WebPartManag er1.DisplayMode = WebPartManager. DesignDisplayMo de
    End Select
    End Sub

    I don't where i'm going wrong
    when i searched for this i came to know that we have to provide a membership provider to handle with sqlserver2000
    but wat is the code that to be added

    how to make sqlserver2000 to be used by the application
    plz help me i tried but i couldn't get the result
    thank u
    archu
  • archu007
    New Member
    • May 2007
    • 28

    #2
    Hi frds

    I got the solution

    Actually in my sqlserver 2000 I don't have "aspnedb" database

    to have this

    1)go to C:\windows\Micr osoft.NET\Frame work\version\

    in this select aspnet_regsql.e xe

    when u select this a wizard will be opened select the required one, and by deafult databse="defaul t"

    note:if u wont change this then by default it will giv name as aspnetDb

    2)click finish

    then it will create a database with name "aspnetDb"

    3) now go to ur application open web.config file and add the following statements

    <connectionStri ngs>
    <add name="MyDb" connectionStrin g="Data Source=YourServ er;Initial Catalog=aspnetd b;Integrated Security=True" providerName="S ystem.Data.SQLC lient"/>
    </connectionStrin gs>
    <system.web>
    <webParts enableExport="t rue">
    <personalizatio n defaultProvider ="MyWebPartsPro vider">
    <providers>
    <add name="MyWebPart sProvider" connectionStrin gName="MyDb" type="System.We b.UI.WebControl s.WebParts.SqlP ersonalizationP rovider"/>
    </providers>
    </personalization >
    </webParts>

    <membership defaultProvider ="AspNetSqlMemb ershipProvider" >
    <providers>
    <clear/>
    <add name="AspNetSql MembershipProvi der" type="System.We b.Security.SqlM embershipProvid er,System.Web, Version=2.0.0.0 ,&#xA;Culture=n eutral,PublicKe yToken=b03f5f7f 11d50a3a" connectionStrin gName="MyDb" applicationName ="/CustomConnectio n"/>
    </providers>
    </membership>
    </system.web>



    4)now run da application

    i don't know whats the use of "personalizatio n and membership" my problem solved

    can anyone tell what is the use of those those 2 elements

    thank u

    Archu

    Comment

    Working...