Thursday 30 April 2015

Bootstrap dropdown menu not working


Today Twitter Bootstrap has become a basic need of the Website Development . Today i am giving some explanation regarding a common mistake while using Twitter Bootstrap . This mistake will happen only when you are trying to create a Navigation Bar for your website / webapplication using Bootstrap NavBar .

So , In order to create a NavBar we must require 3 files -

1. Bootstrap.css file
2. Jquery.js file
3. Bootstrap.js file

So Bootstrap.css file is used for Design and look of Navbar and Now the most important thing due to this you may suffer from an error -

Bootstrap dropdown menu not working 

So , Ever you suffer from this a simple solution is you must first include the jquery.js file or any version of jquery.js file as you wish as shown in example below and then after jquery file you can include bootstrap.js file 

If it still does not work just include the following script code after including the above two js files

<script>
    $(document).ready(function () {
        $('.dropdown-toggle').dropdown();
    });
</script>

A Simple Example of Twitter Bootstrap Navbar is Below :-



<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="css/bootstrap.css" rel="stylesheet" />
    <link href="css/bootstrap.min.css" rel="stylesheet" />


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script>
    $(document).ready(function () {
        $('.dropdown-toggle').dropdown();
    });
</script>




   
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>

       
         <nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Brand</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
        <li><a href="#">Link</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Manage Users <span class="caret"></span></a>
          <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu4">
  <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Regular link</a></li>
  <li role="presentation" class="disabled"><a role="menuitem" tabindex="-1" href="#">Disabled link</a></li>
  <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another link</a></li>
</ul>
        </li>
      </ul>
    <div class="btn-group">
  <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
    Action <span class="caret"></span>
  </button>
  <ul class="dropdown-menu" role="menu">
    <li><a href="#">Action</a></li>
    <li><a href="#">Another action</a></li>
    <li><a href="#">Something else here</a></li>
    <li class="divider"></li>
    <li><a href="#">Separated link</a></li>
  </ul>
</div>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Link</a></li>
     
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>


    </div>
    </form>
</body>
</html>

Tuesday 28 April 2015

ASP.NET MVC Action Return View Not Changing URL

The return View(.......) in Action of Controller is the statement that we use to return the view View for a Particular Controller Request . But Return view will return the view exactly you want and render the view but it will not change or target the user to target url  . The simple solution is below -


Code For an Action -

[HttpPost]
public ActionResult Start(SomeViewModel someViewModel)
{
  ...
  return RedirectToAction("SomeOtherAction");

              
                             or


  return RedirectToAction("Action Name", "Controller Name");
}

So , In code above We are using RedirectToAction instead of using  return view this can be used in total of 6 variants .

I have give 2 of simple one . In Parameter to these actions you need to pass the controller and action name according to variant you choose


Sunday 22 March 2015

The cockroach theory for self development - The Persuit Of Happyness


At a restaurant, a cockroach suddenly flew from somewhere and sat on a lady. She started screaming out of fear. With a panic stricken face and trembling voice,she started jumping, with both her hands desperately trying to get rid of the cockroach. Her reaction was contagious, as everyone in her group also got panicky. The lady finally managed to push the cockroach away but ...it landed on another lady in the group.

Now, it was the turn of the other lady in the group to continue the drama. The waiter rushed forward to their rescue. In the relay of throwing, the cockroach next fell upon the waiter. The waiter stood firm, composed himself and observed the behavior of the cockroach on his shirt. When he was confident enough, he grabbed it with his fingers and threw it out of the restaurant.

Sipping my coffee and watching the amusement, the antenna of my mind picked up a few thoughts and started wondering, was the cockroach responsible for their histrionic behavior?
If so, then why was the waiter not disturbed? He handled it near to perfection, without any chaos. It is not the cockroach, but the inability of the ladies to handle the disturbance caused by the cockroach that disturbed the ladies.

I realized that, it is not the shouting of my father or my boss or my wife that disturbs me, but it's my inability to handle the disturbances caused by their shouting that disturbs me. It's not the traffic jams on the road that disturbs me, but my inability to handle the disturbance caused by the traffic jam that disturbs me. More than the problem, it's my reaction to the problem that creates chaos in my life.

Lessons learnt from the story: I understood, I should not react in life. I should always respond. The women reacted, whereas the waiter responded. Reactions are always instinctive whereas responses are always well thought of. A beautiful way to understand............LIFE.
Person who is HAPPY is not because Everything is RIGHT in his Life.. He is HAPPY because his Attitude towards Everything in his Life is Right..!!,,,,,,,
Really beautiful

Friday 20 March 2015

Thursday 19 March 2015