web stats analysis

It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level.

It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level.
This error can be caused by a virtual directory not being configured as an application in IIS.

To resolve it, Right Click on the virtual directory – select properties and then click on “Create” next to the “Application” Label and the text box. It will automatically create the “application” using the virtual directory’s name. Now the application can be accessed.

When you have sub-directories in your application, you can have web.config file for the sub-directory. However, there are certain properties which cannot be set in the web.config of the sub-directory such as authentication, session state (you may see that the error message shows the line number where the authentication or session state is declared in the web.config of the sub-directory). The reason is, these settings cannot be overridden at the sub-directory level unless the sub-directory is also configured as an application (as mentioned in the above point).

You may get this error when trying to browse an asp.net application. The debug information shows that “This error can be caused by a virtual directory not being configured as an application in IIS.” However, this error occurs primarily out of 2 scenarios.

1. When you create an new web application using visual studio.net, it automatically creates the virtual directory and configures it as an application. However, if you manually create the virtual directory and it is not configured as an application, then you will not be able to browse the application and may get the above error. The debug information you get as mentioned above, is applicable to this scenario. To resolve it, Right Click on the virtual directory – select properties and then click on “Create” next to the “Application” Label and the textbox. It will automatically create the “application” using the virtual directory’s name. Now the application can be accessed.

2. When you have sub-directories in your application, you can have web.config file for the sub-directory. However, there are certain properties which cannot be set in the web.config of the sub-directory such as authentication, session state (you may see that the error message shows the line number where the authentication or sessionstate is declared in the web.config of the sub-directory). The reason is, these settings cannot be overridden at the sub-directory level unless the sub-directory is also configured as an application (as mentioned in the above point). Mostly we have the practice of adding web.config in the sub-directory if we want to protect access to the sub-directory files (say, the directory is admin and we wish to protect the admin pages from unauthorized users). But actually, this can be achieved in the web.config at the application’s root level itself, by specifying the location path tags and authorization

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;

}

Cannot access a disposed object?

Following Solution:

The problem is when you close form that it can not be used anymore you have to reopened.The code you posted tries to stop closing and only hides your window.If you want to doing this then you must set cancel-property true.

Private void Max_FormClosing(object sender, FormClosingEventArgs e)  

{

this.Hide();

this.Parent = null;

Cancel=true;

}

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" })

Limit excerpt length by characters in wordpress

Copy the below code and paste into Function.php.


function get_the_twitter_excerpt(){

$excerpt = get_the_content();

$excerpt = strip_shortcodes($excerpt);

$excerpt = strip_tags($excerpt);

$the_str = substr($excerpt, 0, 20);

return  $the_str;

}

Call this function where you want to display your limeted characters:like below

<?php echo substr(get_the_excerpt(), 0,30); ?>

     //Here..(30) is size of character.(User define)

<?php echo get_the_twitter_excerpt(); ?>

For more reference Click here..

Excerpt or Content Word Limit in WordPress: Redux.

Copy the below code and paste into Function.php.


function excerpt($limit) {

$excerpt = explode(' ', get_the_excerpt(), $limit);

if (count($excerpt)>=$limit) {

array_pop($excerpt);

$excerpt = implode(" ",$excerpt).'...';

} else {

$excerpt = implode(" ",$excerpt);

}

$excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);

return $excerpt;

}

function content($limit) {

$content = explode(' ', get_the_content(), $limit);

if (count($content)>=$limit) {

array_pop($content);

$content = implode(" ",$content).'...';

} else {

$content = implode(" ",$content);

}

$content = preg_replace('/\[.+\]/','', $content);

$content = apply_filters('the_content', $content);

$content = str_replace(']]>', ']]&gt;', $content);

return $content;

}

Call this function where you want to display your limited content:like below.


<?php echo excerpt(25); ?>

		Here..(25) is a size of word.

For more reference Click here..

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+", "_");

}