Friday, September 11, 2009

Tutorial using MySQL with Asp.Net

· 0 comments

If you want to use MySQL Database with Asp.net, then here is a link which explains: http://www.15seconds.com/issue/050407.htm

  • Download of MySQL Server
  • MySQL Administrator
  • MySQL Query Browser
  • .Net Connector (For Asp.net Integration)
The above link has explained in detail, with proper screenshots, from where to download installers, how to install with step by step screens and explanations, and also how to create sample asp.net application with MySQL database, create MySQL database (schema), create MySQL Table, Insert Data, and populate that data in asp.net gridview.

Read More......

Wednesday, September 9, 2009

Using String.Format("{0}", "formatting string"}; in Asp.net

· 0 comments

Many times we want to define formats for date, currency, number etc

For example if we want date in

" 09 September 2009"  - String.Format{0:D}

" 09 September 2009 12:30"  - String.Format{0:f}

Like this various formats for date, month, year, time, currency number etc can be seen at :

http://bit.ly/cctp


Read More......

Tuesday, September 1, 2009

Inserting Data Into Table Using Select Query

· 0 comments

In SQL, sometimes we need to select some data from one table and insert data into another table, this can be done as follows with a simple sql query:

Insert into Table1 (c1, c2, c3, c4, c5)
(Select c1, c2, c3, c4, c5 from Table2)

But make sure that both the tables have same fields, data type..



Read More......

Monday, August 31, 2009

Textbox Watermark using Ajaxtoolkit or By Javascript

· 0 comments

Adding Watermark to textbox can be done in two ways:

1) Using Ajax Toolkit:

<asp:TextBox runat="server" id="txtname"/>
<ajaxToolkit:TextBoxWatermarkExtender ID="TBWE2" runat="server"
TargetControlID="TextBox1"
WatermarkText="Type First Name Here"
WatermarkCssClass="watermarked" />

For more information on Ajax Toolkit please visit:
http://www.asp.net/ajax/

2) Using Javascript
:

<asp:TextBox ID=”txtname” runat=”server” Text = “Please Enter your Name here”
onblur = “TextboxWaterMark(this, event);”
onfocus = “TextboxWaterMark(this, event);”>
</asp:TextBox>

<script type = “text/javascript”>
var Text = “Please Enter your text here”;//black

function TextboxWaterMark(txtid, evnt)
{
if(txtid.value.length == 0 && evnt.type == “blur”)
{
txtid.style.color = “set the color you want”;//red
txtid.value = Text;
}
if(txtid.value == Text && evnt.type == “focus”)
{
txtid.style.color = “set the color you want”;
txtid.value=”";
}
}
</script>

To use in code behind :

txtname.Attributes.Add(”onblur”, “TextboxWaterMark(this, event);”);

txtname.Attributes.Add(”onfocus”, “TextboxWaterMark(this, event);”);

Read More......

Friday, August 28, 2009

Disable button after submit in Asp.net

· 0 comments

Once the user has filled the form details, or did any kind of changes and clicked on submit button, if we want to prevent the duplicate data entry and show other message like "please wait.."'then we can do this as below:

<asp:Button  runat="server" ID="btnsubmit" Text="Submit"
OnClick="btnsubmit_Click" UseSubmitBehavior="false"
OnClientClick="this.disabled=true;this.value='Please wait..';" />

For <asp:imagebutton> usesubmitbehavior will not work hence for this:

<asp:ImageButton runat=”server” ID=”btImageButton”
ImageUrl=”/images/submit.jpeg” OnClick=”btImageButton_Click”
OnClientClick=”javascript: Submit(this);” />

<script type=”text/javascript” language=”javascript”>

function Submit(c){
Page_ClientValidate();
if (Page_IsValid){
c.disabled = true
__doPostBack(c.name, ”);
}
return Page_IsValid;
}

</script>


For furhter reference please visit msdn : http://bit.ly/1CpMBq

Read More......

Wednesday, August 26, 2009

Preview/Show Uploaded Image in Asp.net

· 0 comments

Sometimes, we want to give the preview of the image uploaded through file upload control in asp.net, at the same time.

There is a very nice article on this.. using server side.

http://dotnetspider.com/resources/31341-Show-Uploaded-Image-Image-Control-Asp-net.aspx

In this article, we have one image control, one file upload control and one button control

We upload image using file upload control, and then click on upload button, at the same time the image uploaded will be shown in the image control..

Read More......

Tuesday, August 25, 2009

Getting Last Modified/Created Table, Stored Procedure, Function.. in Sql Server

· 1 comments

Sometimes, we want to know how many tables, stored procedures or functions we have created on a particular day, or on which tables, sps or functions, modifications have occured. All this can be known through a very simple sql query, which is as below:

select name,type,type_desc, create_date, modify_date from sys.objects

where convert(varchar,modify_date,101) = convert(varchar,getdate(),101)

order by modify_date desc

Here

name : - "Its the table or sp or function name"

type: - "To identify a table or sp or function etc.. P, S, U"

type_desc: -"Description whether it is table, sp etc.."

- S = System Table, PK = Primary Key,U = User Table,

- P= Stored Procedure, TF = Table Value Function,

- FN = Scalar Function, D= Default Constraint

create_date: - "Date when it is created"

modify_date: - "Last modified datetime of table, sp,.. etc"

In above query, in place of getdate(), you can pass the date you want, also you can get complete list after removing where condition, just giving order by modified date from sys objects..

Very important when we want to generate scripts for particular tables, sps or function for a particular date.

Read More......