web stats analysis

Archive for September, 2013

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

}

How to get Indian Rupee Symbol in C#.Net?

How to change the background color for an MDI parent form in Visual C#?

Follow below Steps:

Step:1-Create a new Visual C# Windows application.By default Form1 is created.
Step:2-Click the form -> on the View menu -> select Properties Window to view the properties for the form.
Step:3-Set BackColor property to the color that you want.
Step:4-Set the IsMDIContainer property to True.
Step:5-Set the WindowState property to Maximized.
Step:6-Then Double-click the form to view its code window.
Step:7-Copy the below code and paste into form’s load event.

MdiClient ctlMDI;

// Loop through all of the form's controls looking
// for the control of type MdiClient.
foreach (Control ctl in this.Controls)
{
   try
   {
      // Attempt to cast the control to type MdiClient.
      ctlMDI = (MdiClient) ctl;

      // Set the BackColor of the MdiClient control.
      ctlMDI.BackColor = this.BackColor;
   }
   catch (InvalidCastException exc)
   {
      // Catch and ignore the error if casting failed.
   }
}

// Display a child form to show this is still an MDI application.
Form2 frm = new Form2();
frm.MdiParent = this;
frm.Show();
Step:8-On the Project menu -> Add Windows Form.
Step:9-Accept the default name Form2.cs, and then click Open.
Step:10-Finally press F5 to run the application.
Note:-That the background color of the form changes to the color that the Application
Background color is set to in Control Panel.

Error:A potentially dangerous Request.Form value was detected from the client

Add below tag in your web.config file:-


<httpRuntime requestValidationMode="2.0" />

How to Display Recent Posts From A Specific Category In WordPress?

Follow below code:-

Below code could be added where you want to display recent post in your theme.


<?php if ( have_posts() ) : ?>

<?php $catquery = new WP_Query( 'cat=18&posts_per_page=1' ); ?>

<?php while ($catquery->have_posts() ) : $catquery->the_post(); ?>

<?php the_content(); ?>

<?php endwhile; ?>

<?php endif; // end have_posts() check ?>

For more Reference click here.

How to install nuget packages in visual studio?

Follow the below steps:-

Step:1-Open your visual studio.
Step:2-Now click on Tools Menu.
Step:3-And select Package Manager Console inside Library Package Manager
Step:4-After your Package Manager Console will open.
Step:5-Below is a example for install nuget package here I am installing MvcPaging nuget
package.

Example :-

PM> Install-Package MvcPaging
Now press Enter

How to use paging in asp.net MVC 4?