I got some peculiar error after taking the update of the solution from SVN.
So in order to fix it i tried a lot of way but unable to find out the issue as it doesn't show the file where .>>>>>>>>>>>>>>>>> mine or .<<<<<<<<<<<< mine exists. After a through review i find out that it is due to the different version of the files in the respective folder where .obj folder is there.
So, in order to fix this issue, just go to the respective folder and delete the version-ed file names or delete the old ones and rename the latest file to the original one.
The other approach is simply delete the /obj folder in each project that is complaining and re-compile.
This error is caused by the Subversion "Resolved..." function.
Enjoy !
Life is a Short Span, try to earn knowledge in every Field.
Friday, 11 January 2013
Monday, 12 November 2012
Preventing the backbutton not to go to the previous URL when the control is in focus inside a textbox, textarea or radio button in any browser
While developing a website in Asp.net MVC4, I noticed that when my control is in focus inside a text-box or text-area, which are read only, it is moving to the parent of the current URL. In order to solve it i had written a JQuery below which will prevent the back to the parent URL in any browser and in any web developing programming languages.
$(document).keydown(function(e) {
var doPrevent;
if (e.keyCode == 8) {
var d = e.srcElement || e.target;
if (d.tagName.toUpperCase() == 'INPUT' || d.tagName.toUpperCase() == 'TEXTAREA') {
doPrevent = d.readOnly || d.disabled;
}
else
doPrevent = true;
}
else
doPrevent = false;
if (doPrevent)
e.preventDefault();
});
Enjoy!..........
Monday, 5 November 2012
Issue with the sorting the telerik grid for Asp.net MVC
While working on telerik grid , I found a peculiar issue in Internet Explorer(IE) browsers. The issue is that on the column bound HeaderTemplate if you are providing a link for sorting purpose and if you used a label inside the link then the link will not work in IE but will work for all other browsers.
Solution: So, while providing the link text for sorting the grid on that column, just be care full that u must not used any label for that link. See below:
The code below will not work:
column.Bound(m => m.Name).Template(
@<text>
<a target="_blank" href="@item.Url">@item.Name</a>
</text>) .HeaderTemplate(
@<text><a href="javascript:void(0)" class="t-link"> <label>Name<label> </a> ---> This will not work
</text>);
The code below will work:
column.Bound(m => m.Name).Template(
@<text>
<a target="_blank" href="@item.Url">@item.Name</a>
</text>) .HeaderTemplate(
@<text><a href="javascript:void(0)" class="t-link"> Name </a> ---> This will work.
</text>);
Enjoy!.......
Solution: So, while providing the link text for sorting the grid on that column, just be care full that u must not used any label for that link. See below:
The code below will not work:
column.Bound(m => m.Name).Template(
@<text>
<a target="_blank" href="@item.Url">@item.Name</a>
</text>) .HeaderTemplate(
@<text><a href="javascript:void(0)" class="t-link"> <label>Name<label> </a> ---> This will not work
</text>);
The code below will work:
column.Bound(m => m.Name).Template(
@<text>
<a target="_blank" href="@item.Url">@item.Name</a>
</text>) .HeaderTemplate(
@<text><a href="javascript:void(0)" class="t-link"> Name </a> ---> This will work.
</text>);
Enjoy!.......
Friday, 2 November 2012
In MVC4 Telerik grid I got an error that telerik.textbox.js not found in the 'Script\telerik.textbox.js'
This is the tricky one, there is no problem in any where but it is throwing the problem because you might have passed some integer value to the column bound in the telerik grid in mvc3/mvc4.
There are two ways to fix it:
Method 1:
Download the telerik.textbox.js and put in the specified location and it will work fine.
Note: Don't go for this method, since you are adding some more bytes to the size of the Cod.
Method 2:
Just while binding the int value to the grid just convert it into a string. That's all, now your code will work fine
Enjoy!...
There are two ways to fix it:
Method 1:
Download the telerik.textbox.js and put in the specified location and it will work fine.
Note: Don't go for this method, since you are adding some more bytes to the size of the Cod.
Method 2:
Just while binding the int value to the grid just convert it into a string. That's all, now your code will work fine
Enjoy!...
Friday, 26 October 2012
After getting the Ajax result from the Action Method the the view is not updating in mvc3/mvc4
One of my friend while doing a task of a project , he implemented the Ajax call to send request to the action method. he had done it and resend the model to the client side, but the data is not updating in the view.
So, I thought of a while and scrutinized it and found that the model is updated when the data comes from the action method but it is not updating the view. so, here is the trick how to do it.
$.ajax({
data: { retailLocation: $("#ddlLanguages").val().split('-')[1] + "-" + this.value },
url: '/App/index',
success: function (result) {
$("#container").empty().html(result);
$('#container').fadeIn('fast');
},
complete: function (result) {
$("#RetailPartnerLocation option:contains(" + currentselection + ")").attr('selected', 'selected');
},
Error: function (result) { alter("Error occured while processing"); }
});
Here you need to empty the container where the previous data exist and bind the new data to it.
So, I thought of a while and scrutinized it and found that the model is updated when the data comes from the action method but it is not updating the view. so, here is the trick how to do it.
$.ajax({
data: { retailLocation: $("#ddlLanguages").val().split('-')[1] + "-" + this.value },
url: '/App/index',
success: function (result) {
$("#container").empty().html(result);
$('#container').fadeIn('fast');
},
complete: function (result) {
$("#RetailPartnerLocation option:contains(" + currentselection + ")").attr('selected', 'selected');
},
Error: function (result) { alter("Error occured while processing"); }
});
Here you need to empty the container where the previous data exist and bind the new data to it.
How to Show the date like facebooks shows when you provide comments such as 1 min ago, 2 days ago, 1 Month Ago in Asp.Net/ Asp.Net MVC 2/MVC 3/ MVC 4
While working on a project , I need to show the comments published or updated as 1 min ago, 1 Hours ago, so on. So in order to do it I had written a helper class to do it for me.
Here is the code below:
public static string GetFormattedDate(string date)
{
string formattedDate = string.Empty;
TimeSpan ts = System.DateTime.Now - DateTime.Parse(date);
int weeks = (int)(DateTime.Now - DateTime.Parse(date)).TotalDays / 7;
if (ts.Minutes == 0)
formattedDate = "Few Seconds Ago";
if (ts.Minutes > 0 && ts.Minutes < 59)
formattedDate = ts.Minutes + (ts.Minutes == 1 ? " Minute Ago" : " Minutes Ago");
if (ts.Hours > 0 && ts.Hours < 24)
formattedDate = ts.Hours + (ts.Hours == 1 ? " Hour ago" : " Hours ago");
if (ts.Days >= 1 && ts.Days<30)
{
if (ts.Days == 1)
{
formattedDate = "Today";
}
else if (ts.Days>1 && ts.Days < 7)
{
formattedDate = ts.Days + (ts.Days == 1 ? " Day ago" : " Days ago");
}
else
{
formattedDate = (ts.Days / 7).ToString() + ((ts.Days / 7).ToString() == "1" ? " Week Ago" : " Weeks Ago");
}
}
else if (ts.Days >= 30 && ts.Days<365)
{
formattedDate = ts.Days/30 + ( ts.Days<60 ? " Month ago" : " Months ago");
}
else if(ts.Days>=365)
{
formattedDate = ts.Days / 365 + ( ts.Days < 730 ? " Year ago" : " Years ago");
}
return formattedDate;
}
Here is the code below:
public static string GetFormattedDate(string date)
{
string formattedDate = string.Empty;
TimeSpan ts = System.DateTime.Now - DateTime.Parse(date);
int weeks = (int)(DateTime.Now - DateTime.Parse(date)).TotalDays / 7;
if (ts.Minutes == 0)
formattedDate = "Few Seconds Ago";
if (ts.Minutes > 0 && ts.Minutes < 59)
formattedDate = ts.Minutes + (ts.Minutes == 1 ? " Minute Ago" : " Minutes Ago");
if (ts.Hours > 0 && ts.Hours < 24)
formattedDate = ts.Hours + (ts.Hours == 1 ? " Hour ago" : " Hours ago");
if (ts.Days >= 1 && ts.Days<30)
{
if (ts.Days == 1)
{
formattedDate = "Today";
}
else if (ts.Days>1 && ts.Days < 7)
{
formattedDate = ts.Days + (ts.Days == 1 ? " Day ago" : " Days ago");
}
else
{
formattedDate = (ts.Days / 7).ToString() + ((ts.Days / 7).ToString() == "1" ? " Week Ago" : " Weeks Ago");
}
}
else if (ts.Days >= 30 && ts.Days<365)
{
formattedDate = ts.Days/30 + ( ts.Days<60 ? " Month ago" : " Months ago");
}
else if(ts.Days>=365)
{
formattedDate = ts.Days / 365 + ( ts.Days < 730 ? " Year ago" : " Years ago");
}
return formattedDate;
}
How to Write a Extension method to strip html-tags from a rich text Editor in ASP.Net/ MVC
Today while working with CKEditor , I find out that what ever I provide in the Editor body and saved, it is not properly translating the html tags such as paragraph in the Editor body.
So to fix it I had written an extension method to strip the HTML tags as :
public static string StripHtml(string inputString)
{
if (!string.IsNullOrEmpty(inputString))
return Regex.Replace(inputString, "<.*?>", string.Empty);
return string.Empty;
}
How to call: Classname.StripHtml("some string");
So to fix it I had written an extension method to strip the HTML tags as :
public static string StripHtml(string inputString)
{
if (!string.IsNullOrEmpty(inputString))
return Regex.Replace(inputString, "<.*?>", string.Empty);
return string.Empty;
}
How to call: Classname.StripHtml("some string");
How to Minimize Long Title or Overflowed text with less text followed with ellipsis using Jquery or CSS
While working on a project I got a requirement of showing a limited amount of text followed with ellipsis(...) in a telerik grid, to do it I thought I will use the CSS property text-overflow: ellipsis; but unable to succeed. I thought a lot and at last done it with CSS.
What I had done with CSS:
So in order to get the text as "Hello Hai how Are..." I used the following CSS
#divContainer td:first-child + td {height: 45px;width:280px;max-width: 280px;overflow: hidden;
text-overflow: ellipsis; display:block;white-space: nowrap;}
Here divContainer is the Container and td:first-child + td : refers to the second column of a table. InOrder to make it work you need to specify the width,max-width(for IE), white-space and Overflow:hidden and text-overflow: ellipsis;
The output is:
*Note: Here We get the desired result with single line only but I need multiple line with ellipsis, so to do it I followed JQuery.
What I had done with JQuery:
In order to fix this issue I just write below the two line to get multiple lines followed with ellipsis(...)
$("#divContainer td:first-child + td").each(function() {
$(this).text($(this).text().substr(0,75)+"...");
});
The Output is:
Monday, 6 August 2012
Creating your own Folder Locker in Windows Operating systems.
Wow..today I came to know how to write my own folder protector and safe guard my files with out using any software. I started my career in IT as a Software Instructor for teaching people as Computer fundamentals, DOS, MS-Office etc.
At that time I knew that DOS is Powerful and has the capacity to do many low level works but not had the idea that it can create a utility file for me when I am searching for a software to protect it from the guys who stoles the data.
here is the Bat file content.
MyFolderLocker.bat
cls
@ECHO OFF
title Folder Technade
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Technade goto MDLOCKER
:CONFIRM
echo Are you sure u want to Lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Sudarsan "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to Unlock folder
set/p "pass=>"
if NOT %pass% = = sudarsan123$ HERE goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Sudarsan
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Sudarsan
echo Sudarsan created successfully
goto End
:End
@ECHO OFF
title Folder Technade
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Technade goto MDLOCKER
:CONFIRM
echo Are you sure u want to Lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Sudarsan "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to Unlock folder
set/p "pass=>"
if NOT %pass% = = sudarsan123$ HERE goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Sudarsan
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Sudarsan
echo Sudarsan created successfully
goto End
:End
Here the password is sudarsan123$, you can change the password as per your wish.
Lets go for a test:
Copy the bat file which you had created from the above content, now take it to the place where you want to hide the files.
Here create a folder name Sudarsan and store your files you want to protect . Now run the batch file by double clicking it.
For unlocking again , run the file it will ask for password and here i had used sudarsan123$, once you provide the password correctly it will unlock the folder.
Happy Coding......
How to protect your data to be taken through usb in Windows 7 or Win XP
I came to notice few days back that some one is using my system and I found data loss as windows system are prone to data theft easily. so, followed a technique to stop it with out using any software.
There are three ways are there,
1. Make you Registry to protect in such a way that it should not write data into the USB drives
2. Use a .bat file that protect your files and folder with a password.
3. Use a folder locker/ PC Locker for this purpose.
Write Protect to the USB Drives:
Go to the Start menu --> Run---> type Regedit,
You will get the Windows Registry Editor.
Now search for the Following key:
HKEY_LOCAL_MACHINE\System\ControlSet001\Control\StorageDevicePolicies
if the "StorageDevicePolicies" key is not found you can create a new one in HKEY_LOCAL_MACHINE\System\ControlSet001\Control
Now set the Key value to 1 in order to protect it from writing data to the USB Devices.
If you you want to copy data from you computer to usb devices it will not allow.
In order to write the data again to the USB devices you can chane this value to 0 again.
for Windows Xp Machines follow the above same procedure but you the registry key is:
HKEY_LOCAL_MACHINE\System\ControlSet001\Control\StorageDevicePolicies
Note: Just back up the registry before changing any thing so that if u do any thing wrong or the system goes unstable it can be restored.
Happy coding...
Subscribe to:
Posts (Atom)