Web Developer Friend

Archive for the ‘ASP.NET’ Category

Write View State at bottom of the Page for SEO Friendly Site

Posted by: viralsarvaiya on: November 24, 2009

first of all create class file named ‘basepage.vb’ and add this code to class file
then after inherit this class file from page
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
Dim stringWriter As New System.IO.StringWriter
Dim htmlWriter As New HtmlTextWriter(stringWriter)
MyBase.Render(htmlWriter)
Dim html As String = stringWriter.ToString()
Dim StartPoint As Integer = html.IndexOf(“<input type=””hidden”” name=””__VIEWSTATE”””)
If StartPoint >= 0 Then
Dim EndPoint As Integer [...]

Date and Time Format Strings

Posted by: viralsarvaiya on: November 21, 2009

Date and time format strings are used to specify which formatting to apply when a datetime data type is represented as a string.
Date and time format strings fall into either standard or custom format strings. Standard datetime format strings are those that the framework has predefined for commonly used datetime patterns, while custom datetime format [...]

Windows Communication Foundation

Posted by: viralsarvaiya on: November 18, 2009

Windows Communication Foundation (WCF) is the latest service execution environment from Microsoft that enables you to seamlessly expose CLR types as services and consume services as CLR types. WCF is a unified programming model that combines the best of breed features from XML Web Services, .NET Remoting, MSMQ, and COM+ into an integrated platform that [...]

List of HTTP headers

Posted by: viralsarvaiya on: November 13, 2009

HTTP Headers form the core of an HTTP request, and are very important in an HTTP response. They define various characteristics of the data that is requested or the data that has been provided. The headers are separated from the request or response body by a blank line. HTTP headers can be near-arbitrary strings, but [...]

Get HTML code from URL in ASP.NET

Posted by: viralsarvaiya on: November 10, 2009

To get HTML of web page you need only few lines of code.
To start, place two TextBox controls named txtURL and txtPageHTML, and one button control on web form, like in image bellow:

Now, on button’s click event function, place this code:
[ C# ]
// We need these namespaces
using System;
using System.Text;
using System.Net;
public partial [...]

ASP.NET Gridview: Merging Cells

Posted by: viralsarvaiya on: November 4, 2009

I had been searching for a way to merge cells in a GridView
If e.Row.DataItemIndex % 2 = 0 Then
e.Row.Cells(0).RowSpan = 2
e.Row.Cells(1).RowSpan = 2
End If
‘Remove the extra cells created due to row span for odd rows
If e.Row.DataItemIndex % 2 = 1 Then
e.Row.Cells.RemoveAt(0)
e.Row.Cells.RemoveAt(0)
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Center
End If
This code should take every cell in the first and second columns [...]

Retrieving Data as XML from SQL Server

Posted by: viralsarvaiya on: November 2, 2009

All the hype that once surrounded XML is finally starting to die down, and developers are really beginning to harness the power and flexibility of the language. XML is a data descriptive language that uses a set of user-defined tags to describe data in a hierarchically-structured format.
The release of Microsoft SQL Server 2000 a couple [...]

Export GridView Data into CSVFile In Asp.net

Posted by: viralsarvaiya on: October 30, 2009

Steps.
1) Create Simple Web Application.
2) put the below control in to the page (.aspx)
2.1) GridView (id= GridView1)
2.2) Button (id=button1 and Text =Create CSV File)
3) assign data source to GridView
4) on the button_click event put the following code.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Try
‘Create CSV file
Dim objSw As New StreamWriter(Server.MapPath(“~/demo.csv”))
‘get table from GridView1
Dim [...]

Get CheckBoxList values using Javascript

Posted by: viralsarvaiya on: October 28, 2009

I have one CheckBoxList control that binds values at runtime from the database, and when I click on a button from the page, I want to get the values (Database Primary Key) from the CheckBoxList, but for the checked checkboxes only.
Here is the code, what I have achieved so far. This code works fine with [...]

Show Div tag in middle of the page with javascript

Posted by: viralsarvaiya on: October 27, 2009

take a element of Div
<div id=”contentmsg” style=”position: absolute; right:25%; width: 100px; height:100px;visibility: hidden;”>
<img src=”images/loading.gif” width=”50px” height=”50px” />
</div>
suppose we have a dropdown and according to onchange() event this div is visible or hide,
<asp:DropDownList ID=”ddlparavalue” runat=”server”></asp:DropDownList>
in the server side bind the dropdownlist dynamically and add the attribultes as below
ddlparavalue.Attributes.Add(“onchange”, “javascript:void HideOrVisibleDDL();”)
in the head of the html section [...]


Blog Stats

  • 5,866 hits