web stats analysis

code solution Archive

Disabling the right click on images in asp.net.

How to disable right click on images in asp.net?

Add below script between head tag


<script language="JavaScript" type="text/javascript">

var msg = "Right click disable.";
function click(e) {
if (document.all) {
if (event.button == 2 || event.button == 3) {
alert(msg);
return false;
}
}
else {
if (e.button == 2 || e.button == 3) {
e.preventDefault();
e.stopPropagation();
alert(msg);
return false;
}
}
}
if (document.all) {
document.onmousedown = click;
}
else {
document.onclick = click;
}
</script>
}

Add below code between body tag


<div>

Right click on page

</div>

How to use radio button list in asp.net mvc?

Radio button list in mvc

Radio button list in mvc razor.

Follow below Solution:-

@Html.RadioButtonFor(Model => Model.Gender, true) Male

@Html.RadioButtonFor(Model => Model.Gender, false) Female

String was not recognized as a valid DateTime.

String was not recognized as a valid DateTime in asp.net.

String was not recognized as a valid DateTime in c#.

Using DateTime.ParseExact.

string strDate ="10/12/2012";

DateTime date = DateTime.ParseExact(strDate, "dd/MM/yyyy", null);

How to remove extra margin-bottom from floted image?

Remove white space below image

How to remove image padding?

Type following css:

img {

display: block;

}

How can I open a view in a new window with Html.ActionLink?

New window opens on click of actionLink

In Html.ActionLink() How to set target=_blank?

Clicking on actionlink will opening new window.

Follow below Solution:-

@Html.ActionLink("Click here", "About", "Home",null,  new { target = "_blank" })

How to replace spaces with underscores in asp.net?

How can I replace a space in a string with an underscore in C#?

Type following code in code behind.


protected void Page_Load(object sender, EventArgs e)

{

string text= "Good Morning";

Response.Write(Replace(text));

}

static string Replace(string t)

{

return System.Text.RegularExpressions..Regex.Replace(t, @"\s+", "_");

}