Wednesday, 6 March 2013

Refresh only content place holder without refreshing master page


Refresh only content place holder without refreshing master page
  • Create menu.ascx and edit as 
<div class="menu">
    <ul>
        <li><a href="Default.aspx?menu=Home">Home</a></li>
        <li><a href="Default.aspx?menu=Admin">Admin</a></li>
        <li><a href="Default.aspx?menu=About">About</a></li>
    </ul>   
</div>

  • Create 
    1. Home.ascx
    2. Admin.ascx
    3. About.ascx
  • change masterpage.master.cs file
 protected void Page_Load(object sender, EventArgs e)
    {
        LoadMenu();
    }

    private void LoadMenu()
    {
        string menu = Request.QueryString["menu"];
        Control c;
        switch (menu)
        {
            case "Home":
                c = Page.LoadControl(Request.ApplicationPath + "/UserControlMenu/LeftMenuHome.ascx");
                break;
            case "Admin":
                c = Page.LoadControl(Request.ApplicationPath + "/UserControlMenu/LeftMenuAdmin.ascx");
                break;
            case "About":
                c = Page.LoadControl(Request.ApplicationPath + "/UserControlMenu/LeftMenuAbout.ascx");
                break;
            default:
                c = Page.LoadControl(Request.ApplicationPath + "/UserControlMenu/LeftMenuHome.ascx");
                break;
        }
        leftMenuContentPlaceHolder.Controls.Add(c);
    }

CSS: Menu Bar Full Navigational


Source:
  • www.w3schools.com
Menu Bar using CSS:

<!DOCTYPE html>
<html>
<head>
<style>
ul
{
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
}
li
{
float:left;
}
a:link,a:visited
{
display:block;
width:120px;
font-weight:bold;
color:#FFFFFF;
background-color:#98bf21;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
a:hover,a:active
{
background-color:#7A991A;
}

</style>
</head>

<body>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#about">About</a></li>
</ul>
</body>
</html>

Thursday, 28 February 2013

jQuery: Coding



In this short post, I will show you simple jQuery code to clear textbox value. The reason for writing this post is because I have seen many beginner programmers using val() == '', which is wrong as val() is a method that takes argument. It is not a property or attribute. You can call this code on click of button or any other event.

Clear all textbox
1
$(document).ready(function() {
2
    $('input[type=text]').each(function() {

3
        $(this).val('');
4
    });

5
});
Clear single textbox value
1
$(document).ready(function() {
2
   $('#txtID').val(''); //txtID is textbox ID

3
});
Clear textbox value onfocus
1
$(document).ready(function() {
2
    $('#txtID').focus(function() {

3
        $(this).val('');
4
    });

5
});
Associate focus event with every textbox
1
$(document).ready(function() {
2
    $('input[type=text]').focus(function() {

3
        $(this).val('');
4
    });

5
});

jQuery: Intellisense work for external JavaScript file


Simply drag-n-drop the jQuery library from Solution Explorer to the opened external JavaScript file.
image
The Intellisense should work now.
 image

Tuesday, 26 February 2013

BasicLayout Coding

  1. Complete story board
  2. Create tables & state relationship
  3. Create Store procedures
  4. Basic Layout coding:
    • http://masud-aspdotnet-sql2008.blogspot.co.uk/2013/02/aspnet-website-default-layout-example-1.html
  5. Define asp.net theme:
    • http://www.blogger.com/blogger.g?blogID=3635402301628205031#editor/target=post;postID=4822478425935494311
  6. Create Menu Bar
    • Create menu bar using css -http://masud-aspdotnet-sql2008.blogspot.co.uk/2013/03/css-navigational-menu-bar.html
    • Create menu bar using asp.net menu control http://masud-aspdotnet-sql2008.blogspot.co.uk/2013/03/creating-aspnet-menu-control.html
  7. Creat User controls according to story board
    • Create user control
      • OptionHome.ascx
      • OptionAbout.ascx
  8. Update left menu according to Menu Item selected
    • Refresh only content place holder without refreshing master page
      • http://masud-aspdotnet-sql2008.blogspot.co.uk/2013/03/refresh-only-content-place-holder.html
      • http://www.blogger.com/blogger.g?blogID=3635402301628205031#editor/target=post;postID=4249958527028491253
  9. Configure database connectiond
  10. Create Email class
  11. Configure SQL as Role Manager 
  12. Create class to access SQL Role tables 
  13. Create custom login 
  14. Modify the HomeCurrentStudentList user control to show the student list in GridView







SQL Exception: login already have account under a different username 15063

Under-->Database-->Security-->Users there is a user called dbo that is sometimes created with the administrator login so if you try to create it again with different name then it will give you this error message.

ASP.NET: Cannot create a user instance for sql server

Problem: Form authentication is setup and user has been created but cannot login using form authentication.

     1. Have deleted aspnet.log file from solution explorer-app_data folder. then it does show new message.
Cannot open user default database. Login failed.
Login failed for user 'GARDEN\ASPNET'.
    2. So follow the step to in  http://www.blogger.com/blogger.g?blogID=3635402301628205031#overview/postNum=3