Bharath Radhekrishna

Archive for the ‘ASP.NET’ Category

Disabling some of the Textboxes in gridview edit

Posted by: onetidbit on: May 4, 2009

Situation: You need some text boxes disable when gridview is in edit mode.
=======
Solution:
======
1) Bind the Data without Sqldatasource Control
2) In Row Editing write the code:
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
[...]

Storing a image using asp.net

Posted by: onetidbit on: March 30, 2009

Hi, Use this code to store an image in the online server.
Before doing that we must give Permisiions to the folder in which you want to store Images.
Give Read and Write Permissions.
You must use fileupload control to do this:
Here is the code:
string extn =    System.IO.Path.GetExtension(FileUpload1.FileName);
if ((extn == “.jpg”) || (extn == “.gif”) || (extn == [...]

Sometimes we will get the situation where we must insert NULL into datetime column in sql server.
Follow these steps to do that:
1) First Include the namespace:
using System.Data.SqlTypes;
2)  Declare
System.Data.SqlTypes.SqlDateTime getDate;
getDate = SqlDateTime.Null;
3) Insert using command Parameters
cmd11.Parameters.AddWithValue(“@encashed_date”, getDate);
——————————<>—————————————

How to Print a Gridview in ASP.NET 2.0

Posted by: onetidbit on: February 24, 2009

“””””””””””””””””””””””””””””””
<script language=”javascript” type=”text/javascript”>
function getconfirm()
{
return confirm(‘Are you sure you want to change the Folio No?’);
}
function Button1_onclick() {
//open new window set the height and width =0,set windows position at bottom
var a = window.open (”,”, ‘ left = ‘ + screen.width + ‘,top=’ + screen.height + ‘,width=0,height=0,toolbar=0,scrollbars=0,status=0′);
//write gridview data into newly open window
//major change here get innerHTML Of [...]

Tags:

dialog box with line break

Posted by: onetidbit on: January 30, 2009

string script = “alert(\”This dummy matter.\”+’\\n’+\” This dummy matter ‘This dummy matter’ \”+’\\n’+\” This dummy matter\”);”;
Page.ClientScript.RegisterStartupScript(this.GetType(), “script”, script, true);

Please wait on button click

Posted by: onetidbit on: January 30, 2009

C#:::
protected void Button1_Click(object sender, System.EventArgs e)
{
System.Threading.Thread.Sleep(5000);
ClientScript.RegisterClientScriptBlock(this.GetType, “reset”, (“document.getElementById(\’”
+ (Button1.ClientID + “\’).disabled=false;”)), true);
}
protected void Page_Load(object sender, System.EventArgs e) {
Button1.Attributes.Add(“onclick”, (ClientScript.GetPostBackEventReference(Button1, “”) + “;this.value=\’Please wait…\’;this.disabled = true;”));
vb.net:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
System.Threading.Thread.Sleep(5000)
ClientScript.RegisterClientScriptBlock(Me.GetType, _ “reset”, “document.getElementById(’” & Button1.ClientID & “‘).disabled=false;”, True)
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles [...]

Tags:

Using Free Text Box in ASP.NET displaying HTML formatted text

Posted by: onetidbit on: January 9, 2009

Why do we must use FreeTextBox (FTB) control?

This will be useful when we want to display text with HTML formatting with label control.
when you enter the text in FTB it will saves with all the HTML tags in the table.
while displaying the label control along with browser renders HTML.
Before you start with this control you [...]

Some time while viewing your asp.net pages you will encounter with an error like the below:

Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. “
This will be solved if you close [...]

Tags:

Place vb and cs files together in App_Code folder

Posted by: onetidbit on: November 25, 2008

Sometimes while using class files in asp.net we will face the situation where we want to place both Vb and Cs class files.The simple solution is:
1) First make two folders in App_code with foldernames as 1)CSCode 2)VBCode
2) Modify the Web.conig with following code:
<compilation debug=”false”>
<codeSubDirectories>
[...]

Gridview with fixed header

Posted by: onetidbit on: November 17, 2008

Skin:
1 <asp:GridView SkinID=“skinGridView” runat=“server” BackColor=“White” BorderColor=“#DEDFDE” BorderStyle=“Solid” BorderWidth=“1px” CellPadding=“4″ ForeColor=“Black” GridLines=“Vertical”>
2 <HeaderStyle BackColor=“#D7D4D4″ Font-Bold=“True” ForeColor=“#316AC5″/>
3 <RowStyle BackColor=“#FFFFFF” ForeColor=“#333333″/>
4 <AlternatingRowStyle BackColor=“#F7F7F7″ ForeColor=“#333333″ />
5 <HeaderStyle CssClass=“gridHeader“ />
6 </asp:GridView>
CSS:
1 .gridHeader
2 {
3 position:relative;
4 top:auto;
5 [...]