"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Showing posts with label Visual studio 2010. Show all posts
Showing posts with label Visual studio 2010. Show all posts

Thursday, July 4, 2013

Tutorial for Visual Studio Zen Coding

Visual Studio Zen Coding is a visual studio plugin for high-speed HTML, XML, XSL (or any other structured code format) coding and editing.

Just type HTML tag in zen syntax and press alt + z to expand tag to normal form. Its so smooth as touching a flower.

Visual Studio Zen Coding 2012

Saturday, November 5, 2011

One page with multi Default Button

Hi *.*,
As part of my last post.My friend ask me whether its possible to have multi Default Button in one page. Yes it possible.

Saturday, September 24, 2011

Response.RedirectPermanent in asp.net

It is continuous process to either move web pages or content in Web Application development over the years. Search Engine Optimization and page hit count, getting more traffic for the website is the most important things in day today, moving pages or ceasing pages might not find the new page hits in search engines.

For example: Imagine that you have categories of products in your E-Commerce web application. When the old categories are replaced or updated by new categories, each year a page in your site might be replaced or updated accordingly. If any external sites (or even internal pages) have links to the category of these web pages in your web application, when link is clicked for the next time then it would have thrown error.

You would typically use Reponse.Redirect to suppress the error. But this is a manipulation, not actual work. This will work for the visitor but it internally 302 redirect.

Response.Redirect
In previous versions of ASP.NET we are using Response.Redirect that redirects to HTTP 302 found status response in turn redirects the page URL temporarily to the specified page URL. This is extra overhead to the server, performance hit here.

Problems
1. There is a round trip here.
2. 302 redirect is temporary redirect for the page.
3. No Search Engine Optimization (SEO) benefits due to this approach
4. You are neither informing search engine to updated internal indexes nor pass old page rank to new page.

Solution: Issuing permanent HTTP 301 redirect will solve the purpose, directly available in ASP.NET 4.0

Importance of HTTP Response Code 301:
This happens to move some WebPages or entire website from one domain to another or change the URL of some of the pages inside the website most of the time. This is quite difficult for a webmaster who deletes the pages from the old server, maps them to the new domain. In this case webmaster looses SEO that is related to previous links. In order to prevent SEO loss we need to make use of 301 Redirects.
HTTP Response Code 301 instructs the browser that the particular page has been moved permanently from the old location to the new location. The benefit of using 301 Redirects is that the search engine, crawlers store SEO information related to the old link based on 301 redirects. It also informs the search engines that the page location has permanently moved and it needs to index the page from the new location in future. This is really useful for search engines like Bing or Google that will carry over page rank to the new page if this status code is seen.

Response.RedirectPermanent
It’s the method of Page.HTTPReposne class that permanently redirects a requested URL to specified URL and issue HTTP 301response code Moved permanently responses. It uses the URL given by the location header. Unnecessary round trip for the browser is eliminated using this feature. This is used in migrating websites from old domain to new domain especially. As inbound traffic is important for significant usage of the web application this option is very much useful in live web applications as the requested URL is permanently redirected to some location using this mechanism. Since the redirection is HTTP 301 response status, search engine knows the new link that is redirected and results in the redirect.
Syntax :

Response.RedirectPermanent("/newlocation/oldcontent.aspx");

 Stay Tune...
 Have a nice day... 'N happy Coding :)

Monday, September 12, 2011

Nested grid and findControl over child grid

Hi *.*,
Nested grid and findControl over child grid
Over here i have two gridview (GridView1,GridView2) and on 2nd grid  a linkbutton, onclick event i need to extract particular row data. that my need here its go.
 On HTML


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound">
            <Columns>
                <asp:TemplateField HeaderText="Project">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("PkID") %>'></asp:Label>
                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("StrName") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Sub Task">
                    <ItemTemplate>
                        <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" OnRowCommand="GridView2_RowCommand">
                            <Columns>
                                <asp:TemplateField HeaderText="Task Name">
                                    <ItemTemplate>
                                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("name") %>'></asp:Label>
                                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("pk") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Task Status">
                                    <ItemTemplate>
                                        <asp:DropDownList ID="DropDownList1" runat="server">
                                            <asp:ListItem>Open</asp:ListItem>
                                            <asp:ListItem>Close</asp:ListItem>
                                            <asp:ListItem>Finish</asp:ListItem>
                                        </asp:DropDownList>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Select" CommandArgument="<%#((GridViewRow) Container).RowIndex %>">Update</asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <HeaderStyle BackColor="#CCCCFF" />
                        </asp:GridView>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <HeaderStyle BackColor="Maroon" ForeColor="#FFCC00" />
        </asp:GridView>
    </div>
    </form>
</body>
</html>

 
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            GridView1.DataSource = d("SELECT PkID, StrName, DateTimeStamp FROM T2");
            GridView1.DataBind();
        }
    }

    public SqlDataReader d(string _Query)
    {
        SqlCommand cmd = new SqlCommand(_Query, con());
         return cmd.ExecuteReader();

    }

    public SqlConnection  con()
    {
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionDemoString"].ToString());
        con.Open();
        return con;
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        try
        {
            if (e.Row.RowType == DataControlRowType.DataRow)// Bind nested grid view with parent grid view
            {
                string _name = ((Label)e.Row.FindControl("Label3")).Text;
                GridView griedview2 = (GridView)e.Row.FindControl("GridView2");
                griedview2.DataSource = d("SELECT     pk, name, DrpDwn FROM         TBNAME where DrpDwn='" + _name + "'");
                griedview2.DataBind();
            }
        }
        catch (Exception)
        {
           
            throw;
        }
    }
    protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        GridView GridView2 = (GridView)sender;  //find nested grid view
        GridViewRow chrow = (GridViewRow)GridView2.Parent.Parent; // parent grid's row for find any control from parent grid view
        if (e.CommandName == "Select")
        {
            int index = Convert.ToInt32(e.CommandArgument); //use command argument for identify row with nested grid view

            int pid = Convert.ToInt32(((Label)GridView2.Rows[index].FindControl("Label4")).Text); // id from labe4 of nested grid view
            DropDownList childrop = ((DropDownList)GridView2.Rows[index].FindControl("DropDownList1")); // get dropdownlist box of nested grid view
            string status = childrop.SelectedItem.Text;
        }

Hope u guys got it....If any trouble message me. :)
Stay Tune...
Have a nice day... 'N happy Coding :)