Thursday, June 10, 2010

How to use a FileUpload control Inside of Gridview Which Is Inside of UpdatePanel

 <asp:UpdatePanel ID="UpdatePanel3" runat="server">
<Triggers>
                    <asp:PostBackTrigger ControlID="GrdTopBanners" />
                </Triggers>
      <ContentTemplate>
    <asp:Panel ID="pnlCollapseManageTopBanners" runat="server" Width="100%" CssClass="collapsePanelHeader">
        <asp:Image ID="Image12" runat="server" ImageUrl="~/Images/collapse.gif" />
        <asp:Label ID="Label15" runat="server" Text="Show..." CssClass="collapse"></asp:Label><br />
    </asp:Panel>
    <asp:Panel ID="pnlManageTopBanners" runat="server" Width="100%" CssClass="collapsePanel">
        <asp:GridView ID="GrdTopBanners" runat="server" AutoGenerateColumns="False" DataKeyNames="ImageId"
            OnRowCancelingEdit="GrdTopBanners_RowCancelingEdit" OnRowCommand="GrdTopBanners_RowCommand"
            OnRowDataBound="GrdTopBanners_RowDataBound" OnRowDeleting="GrdTopBanners_RowDeleting"
            OnRowEditing="GrdTopBanners_RowEditing" OnRowUpdating="GrdTopBanners_RowUpdating"
            ShowFooter="True" CssClass="grdStyles"
            OnPageIndexChanging="GrdTopBanners_PageIndexChanging" AllowPaging="True" PageSize="20">
            <Columns>
                <asp:TemplateField HeaderText="Image">
                    <EditItemTemplate>
                        <asp:FileUpload  CssClass="systxtarea_a"   ID="FileUploader" runat="server" />
                    </EditItemTemplate>
                    <FooterTemplate>
                        <asp:FileUpload  CssClass="systxtarea_a"   ID="FileUploaderNew" runat="server" />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorImageUploadAdd" runat="server"
                            ErrorMessage="Please add an image." Text="*" ControlToValidate="FileUploaderNew"
                            ValidationGroup="AddTopBanners">
                        </asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidatorImageFileType" runat="server"
                            ErrorMessage="Only .gif,.jpeg,.jpg,.bmp formats are allowed." Text="*" ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.gif|.jpeg|.jpg|.bmp)$"
                            ControlToValidate="FileUploaderNew" ValidationGroup="AddTopBanners">
                        </asp:RegularExpressionValidator>
                    </FooterTemplate>
                    <ItemTemplate>
                        <asp:Image ID="ImgTopBanner" runat="server" Height="50px" Width="50px" ImageUrl='<%# "~/TopBannerLoader.ashx?ImageId=" + Eval("ImageId") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Edit">
                    <EditItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" ValidationGroup="EditTopBanners"
                            CommandName="Update" Text="Update"></asp:LinkButton>
                         <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                            Text="Cancel"></asp:LinkButton>
                        <asp:ValidationSummary ID="ValidationSummaryTopBannersEdit" runat="server" CssClass="TextLabels"
                            ShowMessageBox="True" ShowSummary="False" ValidationGroup="EditTopBanners" />
                    </EditItemTemplate>
                    <FooterTemplate>
                        <asp:LinkButton ID="LinkButton2" runat="server" CommandName="AddNew" ValidationGroup="AddTopBanners"
                            Text="Add New"></asp:LinkButton>
                        <asp:ValidationSummary ID="ValidationSummaryTopBannersAdd" runat="server" CssClass="TextLabels"
                            ShowMessageBox="True" ShowSummary="False" ValidationGroup="AddTopBanners" />
                    </FooterTemplate>
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                            Text="Edit"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Delete">
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkBtnDeleteHotel" runat="server" CausesValidation="False" CommandName="Delete"
                            Text="Delete" OnClientClick="return confirm('Are you certain you want to delete this image?');"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        
        <asp:Label ID="Label16" runat="server" Text="" Visible="false"></asp:Label>
    </asp:Panel>
    <cc1:CollapsiblePanelExtender ID="CollapsiblePanelExtender12" runat="server" TargetControlID="pnlManageTopBanners"
        ExpandControlID="pnlCollapseManageTopBanners" CollapseControlID="pnlCollapseManageTopBanners"
        TextLabelID="Label15" CollapsedText="Manage Top Banners" ExpandedText="Manage Top Banners"
        ImageControlID="Image12" ExpandedImage="~/Images/collapse.gif" CollapsedImage="~/Images/expand.gif"
        Collapsed="True" SuppressPostBack="true">
    </cc1:CollapsiblePanelExtender>
    </ContentTemplate>
          </asp:UpdatePanel>




Add a PostBackTrigger and give the name of the gridview as follows "ControlID="GrdTopBanners""



Monday, June 7, 2010

How to redirect to the login page when using access rules in membership provider

"forms loginUrl="pages/Login.aspx"  name=".ASPXFORMSAUTH"" Add this entry to the Web.Config inside the tag
authentication mode="Forms" .

Thursday, March 25, 2010

Can not restore sql server 2005 Backup

If restoring a .bak file to a new database fails then go to these steps.

Create a new database using this script.

 USE [master]
GO


CREATE DATABASE [Test] ON PRIMARY
( NAME = N'Test', FILENAME = N'C:\Test.mdf' , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'Test_log', FILENAME = N'C:\Test_log.ldf' , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO

Stop sql server service.

then replace the newly created  .mdf & .ldf files with your older .mdf & .ldf files.

Stop sql server service. 

Refresh  your server tree.


Then you are done...

Tuesday, March 23, 2010

Free Sharepoint Discussion Forums

http://www.sharepointjoel.com/Lists/Posts/Post.aspx?ID=234

http://weblogs.asp.net/soever/archive/2005/03/04/385523.aspx

http://www.datasprings.com/Products/SharePointWebParts/MOSSForums.aspx

http://spforums.codeplex.com/releases/view/53

How to remove the “Title” column from a SharePoint Custom List

Have you asked yourself the question: How do I remove the ‘title column’ from a Sharepoint list? It can be annoying trying to figure out how to remove this column from default lists. Often, site admins want their audiences to click on “New Item” in a Sharepoint list and not have to fill out the default ‘Title’ column content type.


I found a great article while surfing internet.This show you how to remove the
"Title" filed from a custom list

Thursday, February 4, 2010

Change Modified Field of Sahrepoint List Using Object Model in c#

When created items in SharePoint via the object model, you can convert a readonly property of that field to be false in order to allow you to set the value of that field. This is particularly useful for setting created and modified dates (all SharePoint lists retain these).

// get the list and set modified property to allow writing
SPWeb web = new SPSite("http://url/to/web").OpenWeb();
SPList selectedList = web.Lists["listname"];
selectedList.Fields["Modified"].ReadOnlyField = false;
selectedList.Fields["Modified"].Update();


// set the item
SPItem newItem = selectedList.Items[0];
newItem["Modified"] = DateTime.Now;
newItem.Update();

// Set readonly back to true
selectedList.Fields["Modified"].ReadOnlyField = true;
selectedList.Fields["Modified"].Update();

Wednesday, February 3, 2010

Firebug has a lite version that can be used in any browser! Obviously it isn’t as functional as the Firefox plug-in, but it helps out none the less. Some things you are normally used to doing in firebug will not be as easy, such as disabling CSS rules and the handy inspect is less functional.

There are 2 ways to activate Firebug lite:

 1. Including an external JavaScript File
 2. Using a bookmarklet

All you have to do is add the following to your head as a javascript
script type='text/javascript'
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'