Saturday, October 23, 2010
Friday, October 8, 2010
dynamically preview large image on mouseover using jquery and css
Steps To Follow :
1) Add CSS Styles :
/* Image Hover **/
A.imageEnlarge
{
border-top-width: 0px;
display: block;
border-left-width: 0px;
background: #ffffff;
float: left;
border-bottom-width: 0px;
width: 65px;
height: 65px;
border-right-width: 0px;
text-decoration: none;
}
A.imageEnlarge IMG
{
border-top-width: 0px;
display: block;
border-left-width: 0px;
border-bottom-width: 0px;
border-right-width: 0px;
}
A.imageEnlarge:hover
{
z-index: 500;
color: #000;
position: relative;
background-color: #ffffff;
text-decoration: none;
}
A.imageEnlarge B
{
padding-right: 10px;
display: block;
padding-left: 10px;
left: -9999px;
padding-bottom: 10px;
padding-top: 10px;
position: absolute;
-o-border-radius: 8px;
-icab-border-radius: 8px;
-khtml-border-radius: 8px;
-moz-border-radius: 8px;
-ms-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
opacity: 0;
filter: alpha(opacity=0);
-o-box-shadow: 5px 5px 2px rgba(0, 0, 0, 0.4);
-icab-box-shadow: 5px 5px 2px rgba(0, 0, 0, 0.4);
-khtml-box-shadow: 5px 5px 2px rgba(0, 0, 0, 0.4);
-moz-box-shadow: 5px 5px 2px rgba(0, 0, 0, 0.4);
-ms-box-shadow: 5px 5px 2px rgba(0, 0, 0, 0.4);
-webkit-box-shadow: 5px 5px 2px rgba(0, 0, 0, 0.4);
box-shadow: 5px 5px 2px rgba(0, 0, 0, 0.4);
-webkit-transition: opacity 0.6s ease-in-out;
width: 401px;
height: 401px;
}
A.imageEnlarge:hover B
{
border-right: #aaa 1px solid;
padding-right: 10px;
border-top: #aaa 1px solid;
padding-left: 10px;
background: #ffffff;
left: 80px;
padding-bottom: 10px;
border-left: #aaa 1px solid;
padding-top: 10px;
border-bottom: #aaa 1px solid;
top: -85px;
opacity: 1.0;
filter: alpha(opacity=100);
width: 401px;
height: 401px;
}
/* Image Hover End */
2) Html Format Must be:
$(document).ready(function() {
$("img[src*='_Small.jpg']").thumbPopup({
imgSmallFlag: "_Small",
imgLargeFlag: "_Large"
});
});
3) Jquery To Be Used :
(function($) {
$.fn.thumbPopup = function(options) {
//Combine the passed in options with the default settings
settings = jQuery.extend({
popupId: "thumbPopup",
imgSmallFlag: "_t",
imgLargeFlag: "_l",
loadingHtml: "Loading"
}, options);
//Create our popup element
popup =
$("
.attr("id", settings.popupId)
.appendTo("b").hide();
//Attach hover events that manage the popup
$(this)
.hover(setPopup);
function setPopup(event) {
var fullImgURL = $(this).attr("src").replace(settings.imgSmallFlag, settings.imgLargeFlag);
$(this).data("hovered", true);
//Load full image in popup
$("")
.bind("load", { thumbImage: this }, function(event) {
//Only display the larger image if the thumbnail is still being hovered
if ($(event.data.thumbImage).data("hovered") == true) {
$(popup).empty().append(this);
$(popup).show();
}
$(event.data.thumbImage).data("cached", true);
})
.attr("src", fullImgURL);
//If no image has been loaded yet then place a loading message
if ($(this).data("cached") != true) {
$(popup).append($(settings.loadingHtml));
$(popup).show();
}
}
//Return original selection for chaining
return this;
};
})(jQuery);
...................Thats All Folks..................... Happy Coding ..!!
Friday, September 24, 2010
How can one check to see if a remote file exists using C#
{
string strFilePath = "http://localhost/images/myimage.jpg";
Uri filePath = new Uri(strFilePath );
if()
{
// File Exists..
}
else
{
// File Does not Exists..
}
}
bool remoteFileExists(string addressOfFile)
{
try
{
HttpWebRequest request = WebRequest.Create(addressOfFile) as HttpWebRequest;
request.Method = "HEAD";
request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
return (response.StatusCode == HttpStatusCode.OK);
}
catch(WebException wex)
{
return false;
}
}
Thursday, September 23, 2010
Lightbox won't work after updatepanel reloads
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Normal page load logic here..
}
else
{
//Reinitialize lightbox on postback.
ScriptManager.RegisterStartupScript(Page, typeof(Page), "init", "initLightbox();", true);
}
}
Friday, August 27, 2010
Thursday, August 26, 2010
ADO.NET Entity (EDMX) : Insert Update and Delete with Relationship
Here I will use a database created by me. There will be two tables connected with each other.
Now I will create TestDB.edmx out of this database.
Insert
using (TestDBEntities ctx = new TestDBEntities())
{
//Create new Department
Dept d = new Dept() { DeptName = "ADO Entity" };
//Create new Employee 1
EmpDept ed1 = new EmpDept() { EmpName = "ADO Employee 1" };
//Create new Employee 2
EmpDept ed2 = new EmpDept() { EmpName = "ADO Employee 2" };
//Add employee to the Dept *OBJECT*
d.EmpDept.Add(ed1);
d.EmpDept.Add(ed2);
//Updating the context
ctx.AddToDept(d);
//Save to Database
ctx.SaveChanges();
}
Update
using (TestDBEntities ctx = new TestDBEntities())
{
//Get an existing Department
Dept dep = (from d in ctx.Dept
where d.DeptId == 22
select d).First();
//Set new Department name
dep.DeptName = "ADO.NET 3.0";
//Create new Employee 2
EmpDept ed2 = new EmpDept() { EmpName = "ADO 2" };
//Add *new* employee to the Dept *OBJECT*
dep.EmpDept.Add(ed2);
//Save to Database
ctx.SaveChanges();
}
Delete
using (TestDBEntities ctx = new TestDBEntities())
{
//Get an existing Department
Dept dep = (from d in ctx.Dept.Include("EmpDept")
where d.DeptId == 22
select d).First();
/*
Needd to do ToList() becuase once you delete
a record then iteration will not be possible.
*/
foreach (EmpDept ed in dep.EmpDept.ToList())
{
//This removes relationship from Context
dep.EmpDept.Remove(ed);
//Delete it from context
ctx.DeleteObject(ed);
}
//Delete the master table
ctx.DeleteObject(dep);
//Save to Database
ctx.SaveChanges();
Saturday, August 21, 2010
Using ImageUrl in sitemap for menu
The imageUrl property shown here is a custom attribute and gets added to the attributes of the SiteMapNode, which can be accessed within the MenuItemDataBound event; this is called for every menu item as it's bound to the underlying siteMapData. So you could have this:
protected void menu1_MenuItemDataBound(object sender, MenuEventArgs e)
{
SiteMapNode node = e.Item.DataItem as SiteMapNode;
if (!string.IsNullOrEmpty(node["imageUrl"]))
e.Item.ImageUrl = node["imageUrl"];
}
To access the attributes you just index into the default collection on the SiteMapNode.
the advantage of this approach is twofold; you don't pollute your title with HTML hacks, and you keep the image data as a separate item, alongside the other site map data.
Friday, August 6, 2010
Convert only first letter of a sentence to uppercase
Friday, July 30, 2010
Thickbox : rel attribute not working for image gallery
- Existing Thickbox Code :
-
- TB_TempArray = $("a[@rel="+imageGroup+"]").get();
Do not include the @ sign in it ie.
- New Thickbox Code :
-
- TB_TempArray = $("a[rel="+imageGroup+"]").get();
..............Njoy..!!
Thursday, July 29, 2010
To Replace Textbox Enter Key With
for Html
for html view :
string strComments = txtComments.Text.Replace("\r\n", "<br >");
strComments = txtComments.Text.Replace("\r", "<br >");
strComments = txtComments.Text.Replace("\n", "<br >");
Now use strComments instead of txtComments.Text...!!!!