Enabling and Disabling a label(sounds crazy right because Label has no functionality but still you will see that requirement from Business quite often)
So here we Go:-
By now You would have noticed that if you use below the label shows as disabled in IE but not in chrome and Firefox:
document.getElementById(CityLabel).disabled = true;
I use a way which worked for me across all browsers( and since we are not causing a post back or something on Label click) so we can USE css here to do our Job
document.getElementById(CityLabel).style.color = "#666";
(above will show the label as Grey or disabled in all browsers and that is what I needed)
Thursday, February 9, 2012
Friday, January 6, 2012
Using Jquery Ajax to Call a WebService
MatheMatics WebService Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
namespace MatheMatics
{
///
/// Summary description for Sample
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod()]
public string SquareOne(string x)
{
return (Convert.ToInt16(x) * Convert.ToInt16(x)).ToString();
}
}
}
Consumer of MatheMatics WebService
I have removed the greater than and less than sign from this .aspx page
@ Page Language="C#"
@ Import Namespace="System.Web.Services"
html
head id="Head1" runat="server"
title ASP.NET AJAX Web Services: Web Service Sample Page /title
script type="text/javascript" src="JS/jquery-1.7.1.min.js"
script type="text/javascript"
$(document).ready(function() {
jQuery.support.cors = true;
$("#sayHelloButton").click(function(event) {
$.ajax({
type: "POST",
url: "http://usphxawnr8a8tdc.aaaaa.edu:55637/Service1.asmx/SquareOne",
data: "{'x': '" + $('#Square').val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
crossDomain: true,
success: function(msg) {
AjaxSucceeded(msg);
},
error: AjaxFailed
});
});
});
function AjaxSucceeded(result) {
alert(result.d);
}
function AjaxFailed(result) {
alert(result.status + ' ' + result.statusText);
}
head
body
form id="form1" runat="server"
h1 ASP.NET AJAX Web Services with jQuery
Enter your Number:
input id="Square" runat="server"
input id="sayHelloButton" value="Square Is: "
type="button" runat="server"
form
body
html
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
namespace MatheMatics
{
///
/// Summary description for Sample
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod()]
public string SquareOne(string x)
{
return (Convert.ToInt16(x) * Convert.ToInt16(x)).ToString();
}
}
}
Consumer of MatheMatics WebService
I have removed the greater than and less than sign from this .aspx page
@ Page Language="C#"
@ Import Namespace="System.Web.Services"
html
head id="Head1" runat="server"
title ASP.NET AJAX Web Services: Web Service Sample Page /title
script type="text/javascript" src="JS/jquery-1.7.1.min.js"
script type="text/javascript"
$(document).ready(function() {
jQuery.support.cors = true;
$("#sayHelloButton").click(function(event) {
$.ajax({
type: "POST",
url: "http://usphxawnr8a8tdc.aaaaa.edu:55637/Service1.asmx/SquareOne",
data: "{'x': '" + $('#Square').val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
crossDomain: true,
success: function(msg) {
AjaxSucceeded(msg);
},
error: AjaxFailed
});
});
});
function AjaxSucceeded(result) {
alert(result.d);
}
function AjaxFailed(result) {
alert(result.status + ' ' + result.statusText);
}
head
body
form id="form1" runat="server"
h1 ASP.NET AJAX Web Services with jQuery
Enter your Number:
input id="Square" runat="server"
input id="sayHelloButton" value="Square Is: "
type="button" runat="server"
form
body
html
Wednesday, November 16, 2011
Calling Server Side Code from Client(AJAX)
Mark the ScriptManager as below:-
Source:-
Use PageMethods.Method(Server)
http://forums.asp.net/t/1323698.aspx/1
Assume Page is a.spx
1.(Removed the greater and less than signs...you need to append them) On a.spx
asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server">
/asp:ScriptManager
2. This is the Client Click Event of Button(on aspx page) from where you would like to Call Server Side Code.
input type="button" id="btnSend" onclick="Send('a','b','c')"
3. Client Method on Aspx Page
function Send(coursme, startme,isme) {
var btn = document.getElementById("btnSend");
btn.disabled = true;
//Server Side Code Call
PageMethods.Send(coursme, startme, isme, Succeeded, Failed);
}
4. You should have a method in a.aspx.cs
[WebMethod]
//public static string Send(string id, int courseRoleId)
public static string Send(string coursme, string startme, string isme)
{
.......................
.......................
Code to Execute on Server
.......................
.......................
}
5. Hopefully you are all set...This is just to give you an idea....
Source:-
Use PageMethods.Method(Server)
http://forums.asp.net/t/1323698.aspx/1
Assume Page is a.spx
1.(Removed the greater and less than signs...you need to append them) On a.spx
asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server">
/asp:ScriptManager
2. This is the Client Click Event of Button(on aspx page) from where you would like to Call Server Side Code.
input type="button" id="btnSend" onclick="Send('a','b','c')"
3. Client Method on Aspx Page
function Send(coursme, startme,isme) {
var btn = document.getElementById("btnSend");
btn.disabled = true;
//Server Side Code Call
PageMethods.Send(coursme, startme, isme, Succeeded, Failed);
}
4. You should have a method in a.aspx.cs
[WebMethod]
//public static string Send(string id, int courseRoleId)
public static string Send(string coursme, string startme, string isme)
{
.......................
.......................
Code to Execute on Server
.......................
.......................
}
5. Hopefully you are all set...This is just to give you an idea....
Handling Ajax Errors a Simple Sample
You need to Modify this sample as this was not getting rendered and i didn't had much time to look so i removed the brackets but the methods are intact mostly...
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
script
void handleClick(object sender, EventArgs e)
{
int a = 0;
int res = 10 / a;
}
void HandleError(object sender, AsyncPostBackErrorEventArgs e)
{
//here we could log the error, and see which exception we're getting in order to set a specific error message
//in this case, I'm just returning the current date/hour back
ScriptManager1.AsyncPostBackErrorMessage = "Ooops...error occurred: " + e.Exception.Message +
DateTime.Now.ToString();
}
/script
form id="form1" runat="server"
asp:ScriptManager ID="ScriptManager1" runat="server" OnAsyncPostBackError="HandleError" /
asp:UpdatePanel runat="server" ID="panel"
contenttemplate
asp:Button runat="server" ID="bt" Text="gerar erro no servidor"
OnClick="handleClick" /
/ContentTemplate
/asp:UpdatePanel
/form
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
script
void handleClick(object sender, EventArgs e)
{
int a = 0;
int res = 10 / a;
}
void HandleError(object sender, AsyncPostBackErrorEventArgs e)
{
//here we could log the error, and see which exception we're getting in order to set a specific error message
//in this case, I'm just returning the current date/hour back
ScriptManager1.AsyncPostBackErrorMessage = "Ooops...error occurred: " + e.Exception.Message +
DateTime.Now.ToString();
}
/script
form id="form1" runat="server"
asp:ScriptManager ID="ScriptManager1" runat="server" OnAsyncPostBackError="HandleError" /
asp:UpdatePanel runat="server" ID="panel"
contenttemplate
asp:Button runat="server" ID="bt" Text="gerar erro no servidor"
OnClick="handleClick" /
/ContentTemplate
/asp:UpdatePanel
/form
Tuesday, May 17, 2011
Is not a Microsoft .NET module While Adding AjaxControl Toolkit
I was trying to add Ajax control toolkit to my ToolBox in VS2008 and was not able to do that.
This post finally helped me out.I had to Turn my Mccafee OFF.
http://forums.asp.net/p/1598878/4061430.aspx
This post finally helped me out.I had to Turn my Mccafee OFF.
http://forums.asp.net/p/1598878/4061430.aspx
Friday, April 1, 2011
Purchasing a Car in USA
As I speak I am just sharing my experince which might be useful to someone who is coming for the first time and want to purchase a car to carry out his living smoothly:).
I don't deny there are definitely smarter people than me :) but yes this is again MY experience...and can/cannot be used as a guide.Dont fix me up for this writeup...
I assume followng holds true for the newcomer:->
1. Is finanacially not very strong in terms of purchainsg the car(0< car value <6-8 grand maxxx) 2. Looking for a used car (given the budget above) .... A car which should not create a problem of whatsoever sorts & does not reqire service/maintenance...having read this just now someone asked me "Realllyy can you get it" Me=>"offcourse not" Be prepared to exercise your judgement/risk-taking skills here ....as i am sure most of you dont even know what an engine looks like or how many cylinders it carries.
3. Wants the best car of town(wishful thinker like me given the budget).
4.Is not having license of US either.
So here you go:-
1. Look for the used cars in craiglist(by owner/dealer both)...follow your car for some time atleast a week
2. Simultaneously look for the cars value in KellyBlueBook (bheb--site) /.....yeah you got it right its a website.
3. The care which matches the price of KBB & The craiglist posting is the right pricing of the car..
4. Now "the car you want" if you dont know i can helep here....
If you are getting all the cars within your budget in craiglist having very high miles apply this logic.
0-50k--any car is good
50-80k---Nissan Sentra/Hyundai sonata/Ultima(if you get one)/Hyundai Elantra/There might be more to this list but i am hanging on here.
80k and above--->Look for Honda Accord/Civic/CRV or Toyota Camry/Corolla only...
(V6 engine is generally more re-selleable item comapred to V4.
And always go for Automatic transmisson instead of manual transmission..Agar apnai car india waaley ghar lekar nahin jaani hai)
5. Once you have zeroed on your car ask for its VIN number from the owner or dealer and look for its CARFAX report (Voilaa what is carfax??)....Carfax (portal) stores all the history of vehicles(if reported)....
Mainly check for salvation/damage/accidents/restored run through Carfax on this Vin Number and if report looks good (before you say its good scan for all possible mysterious and horrifying words of Angrezi/english which can happen to a car like accident...you must have learnt this word by now and damage etc.. etc...)then you are good too....
6. If possible look out for a mechanic nearby your place..who can do a mechanic check of the car (for some dollars offcourse there is nothing like free lunch here my dear friend :)..
7. After you are done with Carfax check and (if possible) mechanic check
you can go for this car....and can purchase it....
Dont review this document please :) I was just feeling bored while working so though of writing this quickly in half an hour......
Thanks for reading..
Enjoy your ride...
Useful Link for Checking Car Emission History (AZ)
http://www.myazcar.com/
http://65.82.88.75/myazcar/histinq.exe/muinput
I don't deny there are definitely smarter people than me :) but yes this is again MY experience...and can/cannot be used as a guide.Dont fix me up for this writeup...
I assume followng holds true for the newcomer:->
1. Is finanacially not very strong in terms of purchainsg the car(0< car value <6-8 grand maxxx) 2. Looking for a used car (given the budget above) .... A car which should not create a problem of whatsoever sorts & does not reqire service/maintenance...having read this just now someone asked me "Realllyy can you get it" Me=>"offcourse not" Be prepared to exercise your judgement/risk-taking skills here ....as i am sure most of you dont even know what an engine looks like or how many cylinders it carries.
3. Wants the best car of town(wishful thinker like me given the budget).
4.Is not having license of US either.
So here you go:-
1. Look for the used cars in craiglist(by owner/dealer both)...follow your car for some time atleast a week
2. Simultaneously look for the cars value in KellyBlueBook (bheb--site) /.....yeah you got it right its a website.
3. The care which matches the price of KBB & The craiglist posting is the right pricing of the car..
4. Now "the car you want" if you dont know i can helep here....
If you are getting all the cars within your budget in craiglist having very high miles apply this logic.
0-50k--any car is good
50-80k---Nissan Sentra/Hyundai sonata/Ultima(if you get one)/Hyundai Elantra/There might be more to this list but i am hanging on here.
80k and above--->Look for Honda Accord/Civic/CRV or Toyota Camry/Corolla only...
(V6 engine is generally more re-selleable item comapred to V4.
And always go for Automatic transmisson instead of manual transmission..Agar apnai car india waaley ghar lekar nahin jaani hai)
5. Once you have zeroed on your car ask for its VIN number from the owner or dealer and look for its CARFAX report (Voilaa what is carfax??)....Carfax (portal) stores all the history of vehicles(if reported)....
Mainly check for salvation/damage/accidents/restored run through Carfax on this Vin Number and if report looks good (before you say its good scan for all possible mysterious and horrifying words of Angrezi/english which can happen to a car like accident...you must have learnt this word by now and damage etc.. etc...)then you are good too....
6. If possible look out for a mechanic nearby your place..who can do a mechanic check of the car (for some dollars offcourse there is nothing like free lunch here my dear friend :)..
7. After you are done with Carfax check and (if possible) mechanic check
you can go for this car....and can purchase it....
Dont review this document please :) I was just feeling bored while working so though of writing this quickly in half an hour......
Thanks for reading..
Enjoy your ride...
Useful Link for Checking Car Emission History (AZ)
http://www.myazcar.com/
http://65.82.88.75/myazcar/histinq.exe/muinput
Nvarchar VS Nvarchar(n) in T-SQL
Recently i encountered a problem which was weired in nature...but yes not very obvious one..took some time to figure out posting here for benefit of other netizens...
Can you spot out the difference between two statments below if yes you are way smarter than me and please log off.....else please continue reading :)
STATEMENT 1:-
***********************************************************************
select EmployeeLookupID from PerformanceReview..EmployeeLookup ELookup
where(
(ELookup.ManagerEmployeeId=N'manager')
OR (ELookup.OneUpManagerEmployeeId=N'manager')
OR (ELookup.EmployeeLookupId=4)
OR (ELookup.ZoneLookupId in
(Select Zlookup.ZoneLookupId from PerformanceReview..ZoneLookup
AS Zlookup where Zlookup.ZoneHRManagerEmployeeId= N'manager')
)
)
Ouput based on my DB records was TWO only and this is what i expected
4
6
************************************************************************
STATEMENT 2:-
*************************************************************************
declare @EmployeeLookupID int
declare @EmployeeID nvarchar
set @EmployeeLookupID =4
set @EmployeeID =N'manager'
select EmployeeLookupID from PerformanceReview..EmployeeLookup ELookup
where(
(ELookup.ManagerEmployeeId=@EmployeeID)
OR (ELookup.OneUpManagerEmployeeId=@EmployeeID)
OR (ELookup.EmployeeLookupId=@EmployeeLookupID)
OR (ELookup.ZoneLookupId in
(Select Zlookup.ZoneLookupId from PerformanceReview..ZoneLookup
AS Zlookup where Zlookup.ZoneHRManagerEmployeeId= @EmployeeID)
)
)
Ouput based on my DB records was one only and this is what i NOT EXPECTED :(
4
*************************************************************************
the difference between the mismatch of expecattions is
if you have noticed the variable to which i am assinging value is nvarchar & this column(ManagerEmployeeId & OneUpManagerEmployeeId & ZoneHRManagerEmployeeId) is nvarchar(100) and there was some implicit casting going on......behind the scenes :(
so I modified my statmenet 2 to below
MODIFIED STATEMENT 2:-
*************************************************************************
declare @EmployeeLookupID int
declare @EmployeeID nvarchar(100)
set @EmployeeLookupID =4
set @EmployeeID =N'manager'
select EmployeeLookupID from PerformanceReview..EmployeeLookup ELookup
where(
(ELookup.ManagerEmployeeId=@EmployeeID)
OR (ELookup.OneUpManagerEmployeeId=@EmployeeID)
OR (ELookup.EmployeeLookupId=@EmployeeLookupID)
OR (ELookup.ZoneLookupId in
(Select Zlookup.ZoneLookupId from PerformanceReview..ZoneLookup
AS Zlookup where Zlookup.ZoneHRManagerEmployeeId= @EmployeeID)
)
)
Ouput based on my DB records was one only and this is what i NOT EXPECTED :(
4
*************************************************************************
and it returned me two rows as i expected...always look up to what is the column datatype and use the variable in your stored procedure also of that data type is what i learnt ......
still trying to figure out why Nvarchar is different than nvarchar(100) in above case...
Take care till than bbye
Can you spot out the difference between two statments below if yes you are way smarter than me and please log off.....else please continue reading :)
STATEMENT 1:-
***********************************************************************
select EmployeeLookupID from PerformanceReview..EmployeeLookup ELookup
where(
(ELookup.ManagerEmployeeId=N'manager')
OR (ELookup.OneUpManagerEmployeeId=N'manager')
OR (ELookup.EmployeeLookupId=4)
OR (ELookup.ZoneLookupId in
(Select Zlookup.ZoneLookupId from PerformanceReview..ZoneLookup
AS Zlookup where Zlookup.ZoneHRManagerEmployeeId= N'manager')
)
)
Ouput based on my DB records was TWO only and this is what i expected
4
6
************************************************************************
STATEMENT 2:-
*************************************************************************
declare @EmployeeLookupID int
declare @EmployeeID nvarchar
set @EmployeeLookupID =4
set @EmployeeID =N'manager'
select EmployeeLookupID from PerformanceReview..EmployeeLookup ELookup
where(
(ELookup.ManagerEmployeeId=@EmployeeID)
OR (ELookup.OneUpManagerEmployeeId=@EmployeeID)
OR (ELookup.EmployeeLookupId=@EmployeeLookupID)
OR (ELookup.ZoneLookupId in
(Select Zlookup.ZoneLookupId from PerformanceReview..ZoneLookup
AS Zlookup where Zlookup.ZoneHRManagerEmployeeId= @EmployeeID)
)
)
Ouput based on my DB records was one only and this is what i NOT EXPECTED :(
4
*************************************************************************
the difference between the mismatch of expecattions is
if you have noticed the variable to which i am assinging value is nvarchar & this column(ManagerEmployeeId & OneUpManagerEmployeeId & ZoneHRManagerEmployeeId) is nvarchar(100) and there was some implicit casting going on......behind the scenes :(
so I modified my statmenet 2 to below
MODIFIED STATEMENT 2:-
*************************************************************************
declare @EmployeeLookupID int
declare @EmployeeID nvarchar(100)
set @EmployeeLookupID =4
set @EmployeeID =N'manager'
select EmployeeLookupID from PerformanceReview..EmployeeLookup ELookup
where(
(ELookup.ManagerEmployeeId=@EmployeeID)
OR (ELookup.OneUpManagerEmployeeId=@EmployeeID)
OR (ELookup.EmployeeLookupId=@EmployeeLookupID)
OR (ELookup.ZoneLookupId in
(Select Zlookup.ZoneLookupId from PerformanceReview..ZoneLookup
AS Zlookup where Zlookup.ZoneHRManagerEmployeeId= @EmployeeID)
)
)
Ouput based on my DB records was one only and this is what i NOT EXPECTED :(
4
*************************************************************************
and it returned me two rows as i expected...always look up to what is the column datatype and use the variable in your stored procedure also of that data type is what i learnt ......
still trying to figure out why Nvarchar is different than nvarchar(100) in above case...
Take care till than bbye
Subscribe to:
Posts (Atom)