Tuesday, February 24, 2009

Useful Link

You will find very UseFul Link Here http://mattberseth.com
http://www.sqlmgmt.com/

How to Get Location Of any Control using Sys.UI.DomElement.getLocation class in Javascript

Hi
Today I want to share a small but very good javascript that is used to get the Location of any control by using the Control using Sys.UI.DomElement.getLocation Class..



Step 1:)
Write the HTML of any control , here suppose we are using the Button .
< id="Btn" text ="FindLocation" onclientclick= "return findLoc(this);" runat="server">

Step 2:)

Write the javascript like below...

function findLoc(ctrlBtn)
{
var location = Sys.UI.DomElement.getLocation(ctrlBtn);
alert(location.x);
alert(location.y);
alert(ctrlBtn.offsetWidth);
alert(ctrlBtn.offsetHeight)
return false;
}

Thanks:
Sanjeev Kumar

Monday, February 16, 2009

Simple Way to Use Cascading DropdownList

How to Use the Cascading Dropdown ? When You need Such type of requirment.Then Please follow the following Steps then You will find that it's very sipmle.
Step 1.) Adding Webservice to bind the Drop DownLIst
A.) Go to Website -> Add New Item ->Choose WebService ->Rename it as you want
(For Example here we have Taken the name of WebService "CascadingDataService.asmx")
B.) Write the CascadingDataService.cs code in App_Code folder as Given Below:-
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
///
/// Summary description for CascadingDataService
///

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService()]
public class CascadingDataService : System.Web.Services.WebService
{
string conString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
public CascadingDataService()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownCountries(string knownCategoryValues, string category)
{
SqlConnection sqlConn = new SqlConnection(conString);
sqlConn.Open();
SqlCommand sqlSelect = new SqlCommand("select * from country order by rowid ", sqlConn);
sqlSelect.CommandType = System.Data.CommandType.Text;
SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlSelect);
DataSet myDataset = new DataSet();
sqlAdapter.Fill(myDataset);
sqlConn.Close();
List cascadingValues = new List();
foreach (DataRow dRow in myDataset.Tables[0].Rows)
{
string categoryID = dRow["ID"].ToString();
string categoryName = dRow["CountryName"].ToString();
cascadingValues.Add(new AjaxControlToolkit.CascadingDropDownNameValue(categoryName, categoryID));
}
return cascadingValues.ToArray();
}
[WebMethod]
public AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownStates(string knownCategoryValues, string category)
{
int categoryID;
StringDictionary categoryValues = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
categoryID = Convert.ToInt32(categoryValues["category"]);
SqlConnection sqlConn = new SqlConnection(conString);
sqlConn.Open();
SqlCommand sqlSelect = new SqlCommand("select * from state where CountryID = @categoryID", sqlConn);
sqlSelect.CommandType = System.Data.CommandType.Text;
sqlSelect.Parameters.Add("@categoryID", SqlDbType.Int).Value = categoryID;
SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlSelect);
DataSet myDataset = new DataSet();
sqlAdapter.Fill(myDataset);
sqlConn.Close();
List cascadingValues = new List();
foreach (DataRow dRow in myDataset.Tables[0].Rows)
{
string SubcategoryID = dRow["Id"].ToString();
string SubcategoryName = dRow["StateName"].ToString();
cascadingValues.Add(new AjaxControlToolkit.CascadingDropDownNameValue(SubcategoryName, SubcategoryID));
}
return cascadingValues.ToArray();
}
}


Step 2.) HTML page where we want to use the Cascading DropDown List :

Country : < id="ddlCountry" runat="server">
< id="CascadingDropDown1" runat="server" category="category" targetcontrolid="ddlCountry" prompttext="--Select Country--" loadingtext="Loading countries..." servicepath="CascadingDataService.asmx" servicemethod="GetDropDownCountries"> < /ajaxToolkit:CascadingDropDown >
State : < id="ddlState" runat="server">
< id="CascadingDropDown2" runat="server" category="subcategory" targetcontrolid="ddlState" parentcontrolid="ddlCountry" prompttext="--Select State--" loadingtext="Loading states..." servicepath="CascadingDataService.asmx" servicemethod="GetDropDownProducts">
< /ajaxToolkit:CascadingDropDown >

By following the Steps described above can make easy to use the Cascading DropDown List.

Thanks:
Sanjeev Kumar

Tuesday, February 10, 2009

popup window which Show on full screen regardless of system resulation

Hi
Today we have to open a popup window which will show on fulll screen. and we can not set the resolution for it b'cz diff sys may have diff resolution we use screen.avilwidth and height peroperty) more detais are bellow :-

window.open("Default5.aspx",null,"fullscreen=yes,status=yes,toolbar=no,menuba
r=no,location=no");
window.resizeTo(screen.availWidth,screen.availHeight);testwindow.moveTo(0,0);//The code positions the popup on the top left corner
of the screen.


// fullscreen=yes it will show as window like when we press F11 button
Some genral features of popup window is shows in following ttable :-
status The status bar at the bottom of the window. toolbar The standard browser toolbar, with buttons such as Back and Forward. location The Location entry field where you enter the URL. menubar The menu bar of the window directories The standard browser directory buttons, such as What's New and
What's Cool resizable Allow/Disallow the user to resize the window. scrollbars Enable the scrollbars if the document is bigger than the window height Specifies the height of the window in pixels. (example: height='350') width Specifies the width of the window in pixels.

Thanks

Mahesh K. Sharma

Friday, February 6, 2009

Fire Item Command on DataList when CheckBox is Clicked

Hi
Today i am wondering to get a problem, when i fired a checkbox (postback enabled) will not wire up the item command on data list. and when i replace checkbox with button it works. 0) then i got a wise solution that keep a button in datalist and explicty genrate its click event when check box is clicked. for this i put code in item databound event of datalist.


// Find controls : -
CheckBox chk1 = (CheckBox)(e.Item.FindControl("chk1"));
Button Button1 = (Button)(e.Item.FindControl("Button1"));
// Add javasCript on onClick event to check box which call click evetnt of button. and after it
// Item command will fire

chk1.Attributes.Add("OnClick",
"javascript:document.getElementById('" + Button1.ClientID + "').click()");

Thansk
HelpOnDesk Team

Wednesday, February 4, 2009

javascript function for generate unique random number

I created a javascript function for generate unique random number. for this function i take object of date and call funciton of getTime() which return milliseconds since 970/01/01 and i also add some random numeric value between 0 to 999 from make it Random.

code snips is as

[script language="javascript"]

function UniqRanDomNumber()

{

var d = new Date();

var randomnumber = Math.floor(Math.random()*1001);

var randomnumber = d.getTime() + randomnumber;

//alert(randomnumber.toString().length);

//alert(randomnumber.toString().substring(6,13)); // If we want to remove right side number whihc are prefixed

document.getElementById("lbl").innerHTML = randomnumber;

return false;

}


[/script]

lbl is id of label where we want to show the uniq random nubmer.


Thanks
HelpOnDesk Team

Tuesday, February 3, 2009

Genrate non Repetitive Random Number.

HI,
Today I have to generate Non Repetitive random number. means a number may me 1234 but not 1224 means no same digit repeat on same number.

javascritp function is as follows :_

function generateRandomNumber(n)
{

if( n > 10)
{
alert('Please Enter 2 to 10');
return false;
}
var randomNo;
var finalArray=new Array();
while(finalArray.length < n)
{
randomNo = Math.floor(Math.random()*10);
if(finalArray.join('').indexOf(randomNo,0) == -1)
{
finalArray[finalArray.length] = randomNo;
}
}
document.getElementById("lbl").innerHTML = finalArray.join('');
return false;
}


Where lbl is id of label where we have to show the random number.

Thanks
Help OnDesk Team

Non Re

Some Important Interview Questions..

Hi ..

After a long long time I am here to post some interview questions on ASP.NET,
I hope that it will help you,


What is framework.
what is CLR? When its role comes?
What is connection pooling and object pooling? Difference
what is Authentication & authorization? types of authentication
what is customerror tag in web.config, its use
what is value type & ref type & where they are store.
what is assesmbly? types...
types of data control.
diff between server.transfer, server.execute & response.redirect
what is session management & types and diff?
how many column in datagrid and what r?
diff between datagrid, datalist, repeator ?
what are events of datagrid and sequence of execution?
what is Exception handling?
what is dataset, datareader, diff?
how many tables can be in dataset?
how to create COM+ in .net?
How to use com component in .net?
What is diff between metadata and menifest
What is http Handler?
What is serialization and its type?
What is uddi , soap , wsdl
What are the files required for deployment of the website?
what are different ways of debugging?
How can we debug an application if we do not have visual studio?
diff between web control , user control and custom control?
When to use remoting and when to use web service?
difference between interface and abstract classes?
From which class thus the web form is derived and what is its
heriarchy?
What is appsettings in web.config?
How we can use the com components in teh asp.net?
What is difference between UDF and stored procedures?
How we get values from stored procedure in asp.net code?
What is the purpose of abstract class?
What is diff between remoting and web service?
How many types of join are there in sql server?
What are different ways of authentication in .Net?
How the sessions are mantained in asp.net?
How we can transfer application from asp to asp.net?
what to do if i want that Class a can not be inherited?

1) What are ISAPI Filters?
2) What is process model in machine.config file?
3) Difference between inetinfo,aspnet_isapi.dll,aspnet_wp.
4) What are Composite controls in .Net ? How do u create them?
5) How can .Net assemblies be decompiled? What are the possible ways to prevent it?
6) Permission Settings in .Net
7) Difference between Http handlers & Http Modules.
8) Custom Configuration section of Web.Config?
9 Explain .Net remoting & its various communication channels
10) What are service oriented components?
11) Explain Serialization & various serialization formatters in .net
12) What is Event Bubbling?
13) How we can use the com components in the asp.net?

What is view state, session object ,cache object ,application object.
What is scope of view state, session object ,cache object ,application object.
Difference between cache object and application object.
Difference between interface and abstract class
What is data relation and write code that
What is trigger and types
Write code for abstract class, interface and define property in interface
Write query for second highest salary
If I use view state and go to second page and redirect to first page then view state maintain or not
On datagrid if I place button then what events will fire
If place datagrid inside another datagrid then what events will fire


Thank Guyes
HelpOnDesk Team

Monday, February 2, 2009

Calculate shipping charge with pay pal

Calculate shipping charge with pay pal

1) With Buy Now button
In this button we can add shipping cost with hidden filed named as shipping and set value of shipping cost. So is is fixed for that item. Sample code for this

[form id="Form2" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"]

[input type="hidden" name="cmd" value="_ext-enter"]
[input type="hidden" name="redirect_cmd" value="_xclick"]
[input type="hidden" name="business" value="mca.mk_1233320111_biz@gmail.com"]
[input type="hidden" name="item_name" value="T-Shirt"]
[input type="hidden" name="amount" value="75.00"]

[input type="hidden" name="shipping" value="15.00"]

[input type="hidden" name="currency_code" value="USD"]
[input type="hidden" name="return" value="http://localhost/HTMLPAYPAL/Default2.aspx"]
[input type="hidden" name="cancel_return" value="http://localhost/HTMLPAYPAL/Default.aspx"]

[input type="submit" value="Buy Now" ]

[/form]

2) Two or more itmes clubed in on buy now button
In this button we add two different items under one click of buttons and set different different values of amount and shipping cost
using hidden value of shipping_x. means shipping_1 for first item and shipping_2 for second item and so on.

Sample code fro this is as follows :-

[form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"]
[input type="hidden" name="cmd" value="_cart"]
[input type="hidden" name="upload" value="1"]
[input type="hidden" name="business" value="mca.mk_1233244379_biz@gmail.com"]
[input type="hidden" name="item_name_1" value="Pink glaf 1"]
[input type="hidden" name="amount_1" value="1.00"]
[input type="hidden" name="shipping_1" value="5.00" ]

[input type="hidden" name="item_name_2" value="IGreen glaf 2"]
[input type="hidden" name="amount_2" value="2.00"]
[input type="hidden" name="shipping_2" value="3.00" ]
[input type="submit" value="PayNow"]
[/form]



3) With Add to Cart button
In this button we add items in paypal shopping cart the shipment cost will override from value of shipping hiddn filed but when we increase quantity in cart and click on update button on paypal shopping the shipping cost will increase from the value of hidden fleld shipping2.

Sample code for this is as follows :-

[form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"]
[input type="hidden" name="cmd" value="_cart"]
[input type="hidden" name="business" value="mca.mk_1233320111_biz@gmail.com"]
[input type="hidden" name="item_name" value="woolen Cap 1"]
[input type="hidden" name="item_number" value="WC1"]
[input type="hidden" name="currency_code" value="USD"]
[input type="hidden" name="amount" value="9.00"]

[input type="hidden" name="shipping" value="2.00"]
[input type="hidden" name="shipping2" value="1.00"]

[input type="hidden" name="return" value="http://localhost/HTMLPAYPAL/Default2.aspx"]
[input type="hidden" name="cancel_return" value="http://localhost/HTMLPAYPAL/Default.aspx"]



[input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but22.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"]
[input type="hidden" name="add" value="1"]
[/form]

if we [input type="hidden" name="shipping2" value="1.00"] set value of sipping2 is 0.00 then shipping cost will not increase for each additional item .

Thanks
HelpOnDesk Team