This was all about Scenario's which I involved in my profession.
Thursday, 13 November 2014
Friday, 12 September 2014
Disable right click option using jquery
$(function(){
$(this).bind("contextmenu", function(e){
e.preventDefault();
alert("right click is disabled"); //not recommended to give alert message
});
});
$(this).bind("contextmenu", function(e){
e.preventDefault();
alert("right click is disabled"); //not recommended to give alert message
});
});
Thursday, 5 June 2014
Very use ful for image map coordinates
for example, you can get full view of each mandal details using the coordinates
http://www.mapsofindia.com/maps/andhrapradesh/districts/prakasam-district-map.jpg
http://www.maschek.hu/imagemap/imgmap
http://www.mapsofindia.com/maps/andhrapradesh/districts/prakasam-district-map.jpg
http://www.maschek.hu/imagemap/imgmap
Sunday, 6 April 2014
call function or do something after ' x ' times in jquery
//--- call function after 10 seconds.
setTimeout("here specify what you want to do", 10000);
Wednesday, 2 April 2014
Reading session value from jquery using WebHandler
using System;
using System.Web;
using System.Web.SessionState;
using System.Web.Script.Serialization;
public class ReadSession : IHttpHandler,IReadOnlySessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
context.Response.Write(new JavaScriptSerializer().Serialize(new
{
Key = context.Request["key"],
Value = (context.Session[context.Request["key"]]!=null && context.Session[context.Request["key"]]!="" ? context.Session[context.Request["key"]]:"")
}));
}
public bool IsReusable
{
get { return true; }
}
}
/*-------( In jquery just call like this )--------*/
$.getJSON('/ReadSession.ashx', { key: key }, function (result) {
alert(result.Value);
});
using System.Web;
using System.Web.SessionState;
using System.Web.Script.Serialization;
public class ReadSession : IHttpHandler,IReadOnlySessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
context.Response.Write(new JavaScriptSerializer().Serialize(new
{
Key = context.Request["key"],
Value = (context.Session[context.Request["key"]]!=null && context.Session[context.Request["key"]]!="" ? context.Session[context.Request["key"]]:"")
}));
}
public bool IsReusable
{
get { return true; }
}
}
/*-------( In jquery just call like this )--------*/
$.getJSON('/ReadSession.ashx', { key: key }, function (result) {
alert(result.Value);
});
Tuesday, 25 March 2014
Confirm message box in jquery
if (confirm("Do you want to delete this record!")) {alert('you clicked on OK button')}
else{alert('you clicked on CANCEL button')}
else{alert('you clicked on CANCEL button')}
Monday, 10 March 2014
create cookies using javascript
/*-----( CREATING COOKIE )------*/
var email =$('#txtUserName').val();
var pwd = $('#txtPassword').val();
var d = new Date();
d.setTime(d.getTime()+(30*24*60*60*1000));
var v_rememberMe = $('#RememberMe').is(':checked') == true ? "Y":"N";
$('#RememberMe').is(':checked') == true ? (document.cookie = "email=" + email + ";expires=" + d.toGMTString() + "") : d.setTime(d.getTime() + (-31 * 24 * 60 * 60 * 1000)); document.cookie = "email=" + email + ";expires=" + d.toGMTString() + "";
/*-------( GETTING COOKIE VALUES )--------*/
$(document).ready(function () {
var mail = getCookie("email");
var expdays = getCookie("expires");
// mail!= "" ? ($('#txtPassword').focus(); $('#txtUserName').val(mail)): $('#txtUserName').focus();
if (mail != "") {
$('#txtPassword').focus(); $('#txtUserName').val(mail); $('#RememberMe').attr('checked', true);
}
else { $('#txtUserName').focus(); }
});
/*----( Getting cookie by Name )----*/
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i].trim();
if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
}
return "";
}
var email =$('#txtUserName').val();
var pwd = $('#txtPassword').val();
var d = new Date();
d.setTime(d.getTime()+(30*24*60*60*1000));
var v_rememberMe = $('#RememberMe').is(':checked') == true ? "Y":"N";
$('#RememberMe').is(':checked') == true ? (document.cookie = "email=" + email + ";expires=" + d.toGMTString() + "") : d.setTime(d.getTime() + (-31 * 24 * 60 * 60 * 1000)); document.cookie = "email=" + email + ";expires=" + d.toGMTString() + "";
/*-------( GETTING COOKIE VALUES )--------*/
$(document).ready(function () {
var mail = getCookie("email");
var expdays = getCookie("expires");
// mail!= "" ? ($('#txtPassword').focus(); $('#txtUserName').val(mail)): $('#txtUserName').focus();
if (mail != "") {
$('#txtPassword').focus(); $('#txtUserName').val(mail); $('#RememberMe').attr('checked', true);
}
else { $('#txtUserName').focus(); }
});
/*----( Getting cookie by Name )----*/
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i].trim();
if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
}
return "";
}
Sunday, 9 March 2014
set checkbox list selection based on the DB values
try
{
string DBVal="1,2,3,";
if (DBVal != "")
{
string[] str = DBVal.Split(',');
foreach (var i in str)
{
ChkBoxList.Items.FindByValue(i).Selected = true;
}
}
}
catch { }
{
string DBVal="1,2,3,";
if (DBVal != "")
{
string[] str = DBVal.Split(',');
foreach (var i in str)
{
ChkBoxList.Items.FindByValue(i).Selected = true;
}
}
}
catch { }
getting checked list box values in asp.net
HERE WE CAN SEPERATE WITH ","
var selected = ChkBoxList.Items.Cast<ListItem>().Where(x => x.Selected);
foreach (var chkItem in selected)
{
string str += chkItem.Value + ",";
}
var selected = ChkBoxList.Items.Cast<ListItem>().Where(x => x.Selected);
foreach (var chkItem in selected)
{
string str += chkItem.Value + ",";
}
Tuesday, 25 February 2014
Don’t run production ASP.NET Applications with debug=”true” enabled
One of the things you want to avoid when deploying an ASP.NET application into production is to accidentally (or deliberately) leave the <compilation debug=”true”/> switch on within the application’s web.config file.
This last point is particularly important, since it means that all client-javascript libraries and static images that are deployed via WebResources.axd will be continually downloaded by clients on each page view request and not cached locally within the browser. This can slow down the user experience quite a bit for things like Atlas, controls like TreeView/Menu/Validators, and any other third-party control or custom code that deploys client resources. Note that the reason why these resources are not cached when debug is set to true is so that developers don’t have to continually flush their browser cache and restart it every-time they make a change to a resource handler (our assumption is that when you have debug=true set you are in active development on your site).
When <compilation debug=”false”/> is set, the WebResource.axd handler will automatically set a long cache policy on resources retrieved via it – so that the resource is only downloaded once to the client and cached there forever (it will also be cached on any intermediate proxy servers). If you have Atlas installed for your application, it will also automatically compress the content from the WebResources.axd handler for you when <compilation debug=”false”/> is set – reducing the size of any client-script javascript library or static resource for you (and not requiring you to write any custom code or configure anything within IIS to get it).
Doing so causes a number of non-optimal things to happen including:
1) The compilation of ASP.NET pages takes longer (since some batch optimizations are disabled)
2) Code can execute slower (since some additional debug paths are enabled)
3) Much more memory is used within the application at runtime
4) Scripts and images downloaded from the WebResources.axd handler are not cached
3) Much more memory is used within the application at runtime
4) Scripts and images downloaded from the WebResources.axd handler are not cached
When <compilation debug=”false”/> is set, the WebResource.axd handler will automatically set a long cache policy on resources retrieved via it – so that the resource is only downloaded once to the client and cached there forever (it will also be cached on any intermediate proxy servers). If you have Atlas installed for your application, it will also automatically compress the content from the WebResources.axd handler for you when <compilation debug=”false”/> is set – reducing the size of any client-script javascript library or static resource for you (and not requiring you to write any custom code or configure anything within IIS to get it).
Monday, 24 February 2014
Expand / Collapse a node in ASP.Net TreeView through XML Attribute
.aspx page:
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="xmlDs" OnPreRender="TreeView1_PreRender" EnableViewState="false"> </asp:TreeView>
<asp:XmlDataSource ID="xmlDs" runat="server" XPath="Modules/Module"></asp:XmlDataSource>
.aspx.cs page:
#region Expand/Collapse Nodes
protected void TreeView1_PreRender(object sender, EventArgs e)
{
SelectCurrentPageTreeNode(tvNav);
}
private void SelectCurrentPageTreeNode(TreeView tvTreeView)
{
tvTreeView.CollapseAll();
string currentPage = System.IO.Path.GetFileName(Request.Path);
if (currentPage != null)
{
ExpandTreeViewNodes(tvTreeView, currentPage);
}
}
private TreeNode ExpandTreeViewNodes(TreeView tvTreeView, string sPathAndQuery)
{
if (tvTreeView != null)
{
if (!string.IsNullOrEmpty(sPathAndQuery))
{
sPathAndQuery = sPathAndQuery.ToLower();
{
TreeNode tnWorkTreeNode = null;
for (int iLoop = 0; iLoop < tvTreeView.Nodes.Count; iLoop++)
{
tvTreeView.Nodes[iLoop].Expand();
tvTreeView.Nodes[iLoop].Selected = true;
if (tvTreeView.Nodes[iLoop].NavigateUrl.ToLower() == sPathAndQuery)
{
return (tvTreeView.Nodes[iLoop]);
}
else
{
tnWorkTreeNode = ExpandTreeViewNodesR(tvTreeView.Nodes[iLoop], sPathAndQuery);
}
if (tnWorkTreeNode != null)
{
return (tnWorkTreeNode);
}
tvTreeView.Nodes[iLoop].Collapse();
}
}
}
}
return (null);
}
private static TreeNode ExpandTreeViewNodesR(TreeNode tvTreeNode, string sPathAndQuery)
{
TreeNode tnReturnTreeNode = null;
if (tvTreeNode != null)
{
tvTreeNode.Expand();
if (tvTreeNode.NavigateUrl.ToLower() == sPathAndQuery)
{
return (tvTreeNode);
}
else
{
tnReturnTreeNode = null;
for (int iLoop = 0; iLoop < tvTreeNode.ChildNodes.Count; iLoop++)
{
tvTreeNode.ChildNodes[iLoop].Selected = true;
tnReturnTreeNode = ExpandTreeViewNodesR(tvTreeNode.ChildNodes[iLoop], sPathAndQuery);
if (tnReturnTreeNode != null)
{
return (tnReturnTreeNode);
}
}
tvTreeNode.Collapse();
}
}
return (null);
}
#endregion
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="xmlDs" OnPreRender="TreeView1_PreRender" EnableViewState="false"> </asp:TreeView>
<asp:XmlDataSource ID="xmlDs" runat="server" XPath="Modules/Module"></asp:XmlDataSource>
.aspx.cs page:
#region Expand/Collapse Nodes
protected void TreeView1_PreRender(object sender, EventArgs e)
{
SelectCurrentPageTreeNode(tvNav);
}
private void SelectCurrentPageTreeNode(TreeView tvTreeView)
{
tvTreeView.CollapseAll();
string currentPage = System.IO.Path.GetFileName(Request.Path);
if (currentPage != null)
{
ExpandTreeViewNodes(tvTreeView, currentPage);
}
}
private TreeNode ExpandTreeViewNodes(TreeView tvTreeView, string sPathAndQuery)
{
if (tvTreeView != null)
{
if (!string.IsNullOrEmpty(sPathAndQuery))
{
sPathAndQuery = sPathAndQuery.ToLower();
{
TreeNode tnWorkTreeNode = null;
for (int iLoop = 0; iLoop < tvTreeView.Nodes.Count; iLoop++)
{
tvTreeView.Nodes[iLoop].Expand();
tvTreeView.Nodes[iLoop].Selected = true;
if (tvTreeView.Nodes[iLoop].NavigateUrl.ToLower() == sPathAndQuery)
{
return (tvTreeView.Nodes[iLoop]);
}
else
{
tnWorkTreeNode = ExpandTreeViewNodesR(tvTreeView.Nodes[iLoop], sPathAndQuery);
}
if (tnWorkTreeNode != null)
{
return (tnWorkTreeNode);
}
tvTreeView.Nodes[iLoop].Collapse();
}
}
}
}
return (null);
}
private static TreeNode ExpandTreeViewNodesR(TreeNode tvTreeNode, string sPathAndQuery)
{
TreeNode tnReturnTreeNode = null;
if (tvTreeNode != null)
{
tvTreeNode.Expand();
if (tvTreeNode.NavigateUrl.ToLower() == sPathAndQuery)
{
return (tvTreeNode);
}
else
{
tnReturnTreeNode = null;
for (int iLoop = 0; iLoop < tvTreeNode.ChildNodes.Count; iLoop++)
{
tvTreeNode.ChildNodes[iLoop].Selected = true;
tnReturnTreeNode = ExpandTreeViewNodesR(tvTreeNode.ChildNodes[iLoop], sPathAndQuery);
if (tnReturnTreeNode != null)
{
return (tnReturnTreeNode);
}
}
tvTreeNode.Collapse();
}
}
return (null);
}
#endregion
Thursday, 20 February 2014
file upload with html control in asp.net and get filename from c#.net
<form id="form1" runat="server" enctype="multipart/form-data"> <input type="file" id="myFile" name="myFile" /> <asp:Button runat="server" ID="btnUpload" OnClick="btnUploadClick" Text="Upload" /> </form>
protected void btnUploadClick(object sender, EventArgs e) { HttpPostedFile file = Request.Files["myFile"]; if (file != null && file.ContentLength ) { string fname = Path.GetFileName(file.FileName); file.SaveAs(Server.MapPath(Path.Combine("~/UPLOADS/", fname))); } }
Friday, 14 February 2014
Jquery Date Picker
<!--( Calender )-->
<link href="../JS/Calender/calender.css" rel="stylesheet" />
<script src="../JS/Calender/jquery-1.10.2.js"></script>
<script src="../JS/Calender/jquery-ui.js"></script>
just call the methods in script tag:
var @datemax, @datemin
$("#txtofferexpires").datepicker("destroy");
$('#txtofferexpires').datepicker({ dateFormat: 'mm/dd/yy', maxDate: @datemax, minDate: @datemin });
destroy clears the history of the calender.
@datemax, @datemin sets for maxdate and mindates which are enabled.
<link href="../JS/Calender/calender.css" rel="stylesheet" />
<script src="../JS/Calender/jquery-1.10.2.js"></script>
<script src="../JS/Calender/jquery-ui.js"></script>
just call the methods in script tag:
var @datemax, @datemin
$("#txtofferexpires").datepicker("destroy");
$('#txtofferexpires').datepicker({ dateFormat: 'mm/dd/yy', maxDate: @datemax, minDate: @datemin });
destroy clears the history of the calender.
@datemax, @datemin sets for maxdate and mindates which are enabled.
Friday, 7 February 2014
IMAGE MOUSEMOVE THEN WE GET ACTUAL IMAGESIZE
/*------( THIS IS FOR IMAGE )--------*/
$('.profileGraphic').live('mousemove', function (event) {
var v_src = $(this).attr('src');
v_src = v_src.replace('&type=square', '');
v_src = v_src.replace('?preset=thumb', '');
v_src = v_src.replace('sz=100', '');
$('#imgpreview').attr('src', v_src);
$('.popup').css({
top: (event.pageY - 10),
left: (event.pageX + 10),
display: 'block'
});
}).live('mouseout', function () {
$('#imgpreview').attr('src', '');
$('.popup').css({ display: 'none' });
return false;
});
<!--IN ASPX/HTML IMAGE POPUP-->
<div class="popup">
<img id="imgpreview" src=""/>
</div>
<!--CSS STYLE -->
.popup
{
position: absolute;
display: none;
z-index: 111111;
border-collapse: collapse;
border: solid 3px white;
}
$('.profileGraphic').live('mousemove', function (event) {
var v_src = $(this).attr('src');
v_src = v_src.replace('&type=square', '');
v_src = v_src.replace('?preset=thumb', '');
v_src = v_src.replace('sz=100', '');
$('#imgpreview').attr('src', v_src);
$('.popup').css({
top: (event.pageY - 10),
left: (event.pageX + 10),
display: 'block'
});
}).live('mouseout', function () {
$('#imgpreview').attr('src', '');
$('.popup').css({ display: 'none' });
return false;
});
<!--IN ASPX/HTML IMAGE POPUP-->
<div class="popup">
<img id="imgpreview" src=""/>
</div>
<!--CSS STYLE -->
.popup
{
position: absolute;
display: none;
z-index: 111111;
border-collapse: collapse;
border: solid 3px white;
}
working with JSON calling Type ' POST '
('#btnsendoffer').live('click', function () {
$('.loadingoffer').show();
$('#sendoffer').css('display', 'none');
try {
/*---( offerterm is ddl selected value )---*/
var _OfferTerm = $("#ddlofferterm option:selected").val();
var _OfferExp = $('#txtofferexpires').val();
var _OfferDesc = $('#txtofferdescription').val();
//alert(_Ichkoffer)
if (_CampaignId != '' && _Ichkoffer != '' && _OfferExp != '') {
$.ajaxSetup({
cache: false
});
$.ajax({
type: 'POST',
url: '../web/Login.asmx.aspx/MakeOffer',
data: '{"strCampaignID":"' + _CampaignId + '","strInfluencerIDs":"' + _Ichkoffer + '","strOfferExp":"' + _OfferExp + '","strOfferTerm":"' + _OfferTerm + '","strOfferDesc":"' + _OfferDesc + '"}',
contentType: 'application/json; charset=urf-8',
cache: false,
datatype: 'json',
success: function (makeoffer) {
if (makeoffer.d == '') {
$('.divofferpopup .divoffercontent').html('<font style="font-size: large; color: red;">Failed to send Offer</font><br/><br/><font>Please contact FYI Team.</font><br/>)
}
else {
$('#sendoffer').css('display', 'none');
$('.divofferpopup .divoffercontent').html('<font style="font-size: large; color: green;">Offer(s) Sent Successfully</font>').css({ "display": "block", "text-align": "center" });
}
},
error: function (xhr, msg) { },
complete: function (xhr, status) {
$('.loadingoffer').hide();
}
});
}
else { alert('Please check the inputs'); return false;}
} catch (error) {
$('.loadingoffer').hide(); hideofferpopup();
}
});
$('.loadingoffer').show();
$('#sendoffer').css('display', 'none');
try {
/*---( offerterm is ddl selected value )---*/
var _OfferTerm = $("#ddlofferterm option:selected").val();
var _OfferExp = $('#txtofferexpires').val();
var _OfferDesc = $('#txtofferdescription').val();
//alert(_Ichkoffer)
if (_CampaignId != '' && _Ichkoffer != '' && _OfferExp != '') {
$.ajaxSetup({
cache: false
});
$.ajax({
type: 'POST',
url: '../web/Login.asmx.aspx/MakeOffer',
data: '{"strCampaignID":"' + _CampaignId + '","strInfluencerIDs":"' + _Ichkoffer + '","strOfferExp":"' + _OfferExp + '","strOfferTerm":"' + _OfferTerm + '","strOfferDesc":"' + _OfferDesc + '"}',
contentType: 'application/json; charset=urf-8',
cache: false,
datatype: 'json',
success: function (makeoffer) {
if (makeoffer.d == '') {
$('.divofferpopup .divoffercontent').html('<font style="font-size: large; color: red;">Failed to send Offer</font><br/><br/><font>Please contact FYI Team.</font><br/>)
}
else {
$('#sendoffer').css('display', 'none');
$('.divofferpopup .divoffercontent').html('<font style="font-size: large; color: green;">Offer(s) Sent Successfully</font>').css({ "display": "block", "text-align": "center" });
}
},
error: function (xhr, msg) { },
complete: function (xhr, status) {
$('.loadingoffer').hide();
}
});
}
else { alert('Please check the inputs'); return false;}
} catch (error) {
$('.loadingoffer').hide(); hideofferpopup();
}
});
Getting more Checkbox:checked values / id's
var _Ichkoffe= $('.selectoption input[name=docheck]:checked').map(function () { return this.value; }).get().join(",");
/*-----( checkbox checked is true / false )-----*/
$('.selectoption input[name=docheck]:checked').attr('checked', false);
$(this).parent().parent().parent().parent().parent().parent().find('.selectoption input[name=docheck]').attr('checked', true)
/*-----(Getting value )------*/
_Ichkoffer = $(this).attr("value");
/*-----( checkbox checked is true / false )-----*/
$('.selectoption input[name=docheck]:checked').attr('checked', false);
$(this).parent().parent().parent().parent().parent().parent().find('.selectoption input[name=docheck]').attr('checked', true)
/*-----(Getting value )------*/
_Ichkoffer = $(this).attr("value");
Getting RadioButton values and id's also label text
var _TEXT= $('input:radio[name=rbnPlans]:checked+ label').text();
var _VAL= $('input:radio[name=rbnPlans]:checked').val();
var _ID = $('input:radio[name=rbnPlans]:checked').attr('id');
var _VAL= $('input:radio[name=rbnPlans]:checked').val();
var _ID = $('input:radio[name=rbnPlans]:checked').attr('id');
Subscribe to:
Comments (Atom)
Extracting Nupkg files using command line
Rename it to zip first then extract files as below 1. Rename-Item -Path A_Package.nupkg -NewName A_Package.zip 2. Make sure to repla...
-
Rename it to zip first then extract files as below 1. Rename-Item -Path A_Package.nupkg -NewName A_Package.zip 2. Make sure to repla...
-
Getting-started Bootstrap Components Grid Positioning
-
Please follow the below URL to get started: Sitecore Helix Visual Studio Templates - Visual Studio Marketplace