Feeds:
Posts
Comments

Archive for September, 2007

control visible and invisible

some time we need to make controls visible or invisible in dot net application. We should not do it manually every time. Here is  a small method which  can do that. You just send you visible and invisible controls as parameter.

public void VisiableInvisiable(Control[] visiables, Control[] invisiables)
{
foreach( Control visiable in visiables )
{
visiable.Visible = true;
}
foreach( Control invisiable in invisiables )
{
invisiable.Visible = false;
}
}

call this function this way

Control[] visiable= {this.pnlShowImage,this.btnAdd};
Control[] invisiable = {this.pnlUploadImage,this.btnCancel};
VisiableInvisiable(visiable, invisiable);

Read Full Post »

Login failed for user Machinename\ASPNET

I faced that problem when i run my application from localhost. Got the solution

Go to command prompt and write these commands. Take care of the spelling database name and tablename.

cd C:Program FilesMicrosoft SQL Server80ToolsBinn

osql -E -S localhost -Q “sp_grantlogin ‘MYCOMPUTERASPNET'”

osql -E -S localhost -d DatabaseName -Q “sp_grantdbaccess ‘MYCOMPUTERASPNET'”

osql -E -S localhost -d DatabaseName -Q “sp_addrolemember ‘db_owner’, ‘MYCOMPUTERASPNET'”

–Don’t forget to change you computer name and database name

Read Full Post »

paging in asp:DataList

asp:DataList has to paging option by default but it is easy to make pagination in datalist using “PagedDataSource Class”

HTML code is:

<table width=”100%”>
<tr><td>
<asp:DataList ID=”dlPhotos” Runat=”server” Width=”100%” ItemStyle-HorizontalAlign=”Left” RepeatLayout=”Table” RepeatDirection=”Horizontal” RepeatColumns=”4″ OnItemDataBound=”dlPhotos_ItemDataBound”>
<ItemTemplate>
<asp:Image id=”imgThumbnail” runat=”server” borderSize=”5″ />
</ItemTemplate>
</asp:DataList>
</td></tr>
<tr><td>
<table width=”100%”>
<tr>
<td align=”left”><asp:LinkButton runat=”server” ID=”lnkPrev” OnClick=”lnkPrev_Click” >Prev</asp:LinkButton></td>
<td align=”right”><asp:LinkButton runat=”server” ID=”lnkNext” OnClick=”lnkNext_Click” >Next</asp:LinkButton></td>
</tr>
</table>
</td></tr>
</table>

Code for the pagination is:

public void ShowPhotos()
{
try
{
PagedDataSource objPage = new PagedDataSource();
DataSet dsImgs = ….\datasource
objPage.AllowPaging=true;
objPage.DataSource = dsImgs.Tables[0].DefaultView;
objPage.PageSize = 12;
objPage.CurrentPageIndex = CurrentPage; //CurrentPage is a static variable
dlPhotos.DataSource = objPage;
dlPhotos.DataBind();
}
catch (Exception ex)
{
lblError.Text = ex.Message ;
}
}
protected void lnkPrev_Click(object sender, EventArgs e)
{
CurrentPage -=1;
ShowPhotos();
}
protected void lnkNext_Click(object sender, EventArgs e)
{
CurrentPage+=1;
ShowPhotos();
}

thats just a sample, please customize it for your works

Read Full Post »

Components of Ajax

Ajax components are:

1. Javascript:  Scripting language that commonly hosted in a browser to add interactively to HTML pages

2. DOM (Document Object Model): DOM is leveraged to efficiently redraw portions og hte pages.

3. CSS (Cascading Style Sheets) : modify the exterior of the user interface interactively

4. XMLHttpRequest: opposed to performing a full-page refresh or postback

Read Full Post »