// open new window with specified pathRead More......
function OpenWindow(url)
{
newwindow = window.open(url, 'mywindow', 'width=500,height=400');
}
Now In .aspx.cs page or server side to use the javascript window open you have to use the following code
StringBuilder popupScript = new StringBuilder();
popupScript.Append("");
// if you are using script manager - update panel then this
ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "PopupScript", popupScript.ToString(), false);
//else
Page.RegisterStartupScript("PopupScript", popupScript.ToString());
Sunday, October 25, 2009
Open a New Window On Server Side using Javascript Code in Asp.net
Labels: Asp.net, Javascript
Saturday, October 24, 2009
Add "Select" Option To Dropdown list in Asp.net
There are many ways to add select option to dropdown list.. Here in this post i will list some of the ways: 1)
Labels: Asp.net
Friday, September 11, 2009
Tutorial using MySQL with Asp.Net
If you want to use MySQL Database with Asp.net, then here is a link which explains: http://www.15seconds.com/issue/050407.htm
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.
Wednesday, September 9, 2009
Using String.Format("{0}", "formatting string"}; in Asp.net
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 :
Labels: Asp.net
Tuesday, September 1, 2009
Inserting Data Into Table Using Select Query
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..
Labels: Sql Server
Monday, August 31, 2009
Textbox Watermark using Ajaxtoolkit or By Javascript
Adding Watermark to textbox can be done in two ways:
1) Using Ajax Toolkit:Read More......
<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);”);
Labels: Ajax, Asp.net, Javascript
Friday, August 28, 2009
Disable button after submit in Asp.net
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"Read More......
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
Labels: Asp.net
Wednesday, August 26, 2009
Preview/Show Uploaded Image in Asp.net
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..
Labels: Asp.net
Tuesday, August 25, 2009
Getting Last Modified/Created Table, Stored Procedure, Function.. in Sql Server
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......
Labels: Sql Server
Saturday, August 22, 2009
Changing Css Class or Style At Run time dynamically in Asp
You can add/change css style or add new attributes to current style at runtime, in asp.net code behind.
Lets say you have:
Download
Now if we want to change its class dynamically then in code behind we have to do:
linktemp.Attributes.Add(”class”, “verdana13greynormalitalic”);
if we want to change its text-decoration under style then,
linktemp.Style.Add(”text-decoration”, “none”);
in the similar you can add new styles, change visible option to true/false,
linktemp.Style.Add(”display”, “block”);
Labels: Asp.net
Thursday, August 20, 2009
How to Get Table Structure Using SQL Query
Sql life made so easy..
See how..
View/Copy, structure of table in sql in just one line query….
select * from tablename where 1<>1
cheers…
Labels: Sql Server
Limiting the number of records to be displayed in Crystal Report
You might be working with crystal reports, and so must have a noticed that number of records displayed in crystal report are variable, sometimes, it displays 8, sometimes 10.. and so on according to the data, it sets it accordingly.
But we can handle this scenario i.e we can specify how many records we want the crystal report to display. For this you need to follow the below instructions:
To make it show 10 records per page do the following
1. Open the report in Design View
2. Right click on the Details section and select Section Expert
3. Make sure the Details section is selected in the Section Expert dialog box. Check the box that says “New Page After”
4. Click the formula editor button to the right of the checkbox.
5. Enter the following formula
if Remainder (RecordNumber, 10) = 0 then true else false
6. Click Save and Close and then click OK.
If you run the report it should break after each 10 rows.
Labels: Asp.net
Wednesday, July 15, 2009
Silverlight: Live Silverlight Toolkit Samples With their Documentation
Are you Learning Silverlight, then you must get started with silverlight controls.
And for this microsoft provides you with live silverlight toolkit samples.
You can interact with them and learn each and every control at your lease.Along with sample controls, it also has documentation explained for each control.
Below are the live links for Silverlight Toolkit:
http://silverlight.net/samples/sl3/toolkitcontrolsamples/run/default.html
http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/index.htm
Documentation Link:
http://msdn.microsoft.com/hi-in/library/cc838158(en-us,VS.95).aspx
Labels: Silverlight
Monday, June 29, 2009
Flex: Developing a Simple Video Player with
This tutorial will explain you how to develop a video player in flex by making use of <mx:VideoDisplay>.
It is a very simple and easy to implement, within seconds you will be able to build and play videos.
<mx:VideoDisplay> is a flex component for playing video files.
In the below link, the author has beautifully explained the process with proper description and screenshots.
You can also view the demo and download the source code.
http://www.riacodes.com/flex/basic-video-player-in-flex/
Labels: Flex
Friday, June 26, 2009
CRUD(Create/Insert/Update/Delete) with Asp.net MVC Framework, Linq To Sql (.dbml)
This article will explain you how to create, read, insert, update, delete operations with asp.net mvc with Linq To Sql (.dbml).
Very nice article who are beginners with asp.net mvc framework.
http://blogs.microsoft.co.il/blogs/bursteg/archive/2009/02/03/create-a-strongly-typed-crud-ui-with-asp-net-mvc-rc.aspx
Labels: Asp.net
Thursday, June 25, 2009
CRUD(Create/Insert/Update/Delete) with Asp.net MVC Framework, ADO.Net Entity Data Model
This article will explain you how to create, read, insert, update, delete operations with asp.net mvc with ado.net entity model.
Very nice article who are beginners with asp.net mvc framework.
Read More......
Labels: Asp.net
Thursday, June 18, 2009
Import Excel Spreadsheet Data into SQL Server Database Table
There are many ways to import/export excel data into sql server table.
Using SqlBulkCopy Common Method for sql server 2005/2008:
http://davidhayden.com/blog/dave/archive/2006/05/31/2976.aspx
In SqlServer 2005 Using Integration Services
Using Sql Server 2005 Import and Export Wizard
Using Sql Server 2008 Import and Export Wizard
http://dotnetslackers.com/articles/sql/Importing-MS-Excel-data-to-SQL-Server-2008.aspx
Read More......Labels: Sql Server
Wednesday, June 3, 2009
Implementing Search in ASP.NET with Google CustomSearch
Going to add search functionality for your website... why not let google do this task.. it would be easier and user friendly..
With those who are unaware of Google Custom Search :
"With Google Custom Search, you can harness the power of Google to create a customized search experience for your own website"
- Include one or more websites, or specific webpages
- Host the search box and results on your own website
- Customize the look and feel of the results to match your site
For more info on google custom search click here
So lets see how to implement search in asp.net with google custom search..
Here is the step by step procedure very nicely explained in the below article..
http://dotnetslackers.com/articles/aspnet/Implementing-Search-in-ASP-NET-with-Google-Custom-Search.aspx Read More......
Labels: Asp.net
Tuesday, June 2, 2009
Get Only Date from Datetime in Sql
Sometimes we need to have only date from datetime field in sql.
There are number of ways to accomplish that:
Suppose we take current date
select getdate()
now to take only date from current date excluding time, we do as follows in various ways:
select DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))
select convert(varchar,getdate(),101)
select convert(char(8),getdate(),1)
select cast(cast(getdate() as int) as datetime)
select cast(convert(varchar,getdate(),110) as datetime)
Labels: Sql Server
Monday, June 1, 2009
Adding eWorld.UI (Excentrics World) Calendar Popup, TimePicker.. etc in Asp.net
You might be in need of Calendar popup or Time Picker in asp.net. I have being using eworld's calendar popup and time picker control since many years.. and all i can say that they are fantastic fully loaded with various features... No Need of taking a textbox and a calendar control for binding date.. and adding different validations for valid date, past and future date validation... now all that comes in one place just drag and drop one calendar popup control and it will give you access to multiple features..
Also there is no time picker control available in our asp.net toolbox.. i searched a lot over the internet and i found this one..
You can download the eworld ui toolkit from :
http://www.eworldui.net/Download.aspx
Toolkit is available for various .net versions whether it is 1.0, 2.0 or 3.5
Once Downloaded, unzip the rar file and install the given exe..
Also, Once done copy the eWorld.UI.dll and paste it in the bin folder of your web application and then right click the web site and add reference of that dll.
Then In the Visual Studio ->View ->Tool box -> Right Click ->Add Tab -> give Eworld Toolkit (as name) - > Right click ->choose items and browse to the eworld ui dll and once done you will see many contorls under that tab in the tool box..
I have been using
CalendarPopup
Time Picker
RangeValidator
CustomValidator
MaskedTextbox...
there are lots of other controls too which you can try at your lease..
Once done.. you can drag and drop the calendar popup on to the aspx page and you will see:
<ew:CalendarPopup ID="tb_startupdate"
runat="server" ControlDisplay="TextBoxImage" ImageUrl="~/Images/dtpicker.jpeg">
</ew:CalendarPopup>
Labels: Asp.net
