Uğur UMUTLUOĞLU
Web Technologies, Microsoft and .NET Technologies

Paging in ListView Over QueryString

Thursday, 16 July 2009 11:11 by ugur

ListView that comes with ASP.NET 3.5 presents considerably a flexible structure. In addition to all operations of GridView, also Insert operation can be done by using this control. On the other side, we can compose the HTML output as the way we want. To perform this kind of process was nearly impossible in GridView.

Another advantage of ListView is that we can do paging operation over QueryString! ListView control does the paging operations on a control named DataPager(DataPager has also come with ASP.NET 3.5). ListView control that is formed ordinarily do the paging operations by LinkButtons included in DataPager; thus JavaScript functions called as a result of Postback operation help doing paging operation. So, there won’t be any change in the URL of the page.  If we want paging operation to be done by a value like PageNo carried on QueryString as UrunListele.aspx?SayfaNo=3, the only thing we must do is that to assign a value like SayfaNo to the QueryStringField property of DataPager control. I also want to mention about this property; you can define how many records will be seen in one page by using PageSize property of DataPager.  The changes made in DataPager control and an example screen output can be seen below.

<asp:DataPager ID="DataPager1" runat="server" QueryStringField="SayfaNo" PageSize="15">

    ...

</asp:DataPager>


Actually, it is a very important and useful tip for users to reach the pages they desired over QueryString and for search engine improvement(SEO).

Tags:   , ,
Categories:   ASP.NET
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Using More Than One DefaultButton in a Page

Wednesday, 1 July 2009 08:52 by ugur

We can assign the ID value of a button control to DefaultButton property in <form> element in order to send the form information filled by the user to the server easily by button object in ASP.NET pages. By this way, the information given in the form can be sent to server when user push Enter key from the keyboard without clicking the button. If there are different forms are included in our page (for example there is a login form at the left of the page and sign up form at the right of the page), how can we make the related button clicked when the user pushes Enter key from the keyboard after filling one of the forms? We can handle this situation again by using DefaultButton property but not the DefaultButton property of <form> element!

Firstly, we must locate both of the forms in Panel controls for solving this situation. Actually, Panel control has DefaultButton property too. Therefore, the forms will function as we want, if we assign the ID value of the button that is included inside of the panel and will do the Submit operation, to the DefaultButton property of the relevant Panel. If you have another form besides these panels and if you want the submit button in this form to be triggered when the Enter key is pushed outside the panels, you can use DefaultButton property of <form> element anyway.  When you test the code snippet given below in your project, you can clearly see the situation.

Default.aspx
<
form id="form1" runat="server" defaultbutton="button1">

    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

    <asp:Button ID="button1" runat="server" Text="Button-1" OnClick="btn_Click" />

    <br />

    <asp:Panel ID="panel1" runat="server" BackColor="LightGreen" DefaultButton="button2" Width="300">

        <asp:TextBox ID="text1" runat="server"></asp:TextBox>

        <asp:Button ID="button2" runat="server" Text="Button-2" OnClick="btn_Click" />

    </asp:Panel>

    <asp:Panel ID="panel2" runat="server" BackColor="LightBlue" DefaultButton="button3" Width="300">

        <asp:TextBox ID="text2" runat="server"></asp:TextBox>

        <asp:Button ID="button3" runat="server" Text="Button-3" OnClick="btn_Click" />

    </asp:Panel>

</form>



Default.aspx.cs

protected
void btn_Click(object sender, EventArgs e)

{

    Response.Write("Clicked button: " + ((Button)sender).Text);

}

Tags:  
Categories:   ASP.NET
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed
 
Add to Technorati Favorites