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



      

ASP.NET Themes: How to define in web.config


How to: Define ASP.NET Themes:

  1. In the solution explorer select the project-->
    • Right click and point to ASP.NET folder-->Then select Theme
  2. Select the newly created theme folder-->
    • Right click and you can add .css file or .skin file using add new item option
Note: Sometimes it does not work. Then
  1. Rename the current theme
  2. Create a new theme and rename as you want.
  3. Now run the program and it will work without error.
In the web.config file:

<!--theme settings-->
    <pages theme="DefaultTheme"/>


In order to change theme dynamically add the following code in the class file:


protected void Page_PreInit(object sender, EventArgs e)
{
string theme = "BlueSkin"; // setting the value to none
if (Page.Request.Form.Count > 0)
{
// "Themes" is the ID of dropdownlist
theme = Request["themes"].ToString();
 }
Page.Theme = theme; // applying themes to the overall page
}





.NET Framework 3.0
21 out of 26 rated this helpful Rate this topic
You can define your own page or global themes. Themes consist of several supporting files, including style sheets for page appearance, control skins to decorate server controls, and any other supporting images or files that make up the theme.

To create a page theme

  1. Create a new folder named App_Themes in your Web site.
    NoteNote
    The folder must be named App_Themes.
  2. Create a new subfolder of the App_Themes folder to hold your theme files. The name of the subfolder is the name of the theme. For example, to create a theme named BlueTheme, create a folder named \App_Themes\BlueTheme.
  3. Add files to your new folder for skins, style sheets, and images that make up the theme.

To create a global theme

  1. Create a Themes folder using this path:
    iisdefaultroot\aspnet_client\system_web\version\Themes
    
    For example, if the default Web root folder is in C:\Inetpub\wwwroot on the Web server, the new Themes folder might be this:
    C:\Inetpub\wwwroot\aspnet_client\system_web\version\Themes
    
    NoteNote
    The folder name for global themes is Themes, not App_Themes, as it is for page themes.
  2. Create a theme folder as a subfolder of the Themes folder. The name of the subfolder is the name of the theme. For example, to create a global theme named BlueTheme, create a folder named ...\Themes\BlueTheme.
  3. Add files to your new folder for skins, style sheets, and images that make up the theme.

To create a skin

  1. Create a new text file in your theme subfolder with a .skin extension.
    The typical convention is to create one .skin file per control, such as Button.skin or Calendar.skin. However, you can create as many or as few .skin files as you need; skin files can hold multiple skin definitions.
  2. In the .skin file, add a normal control definition (using declarative syntax), but include only the properties you want to set for the theme and do not include an IDattribute. The control definition must include the runat="server" attribute.
    The following example shows a default control skin for a Button control, defining the color and font for all Button controls in the theme:
    <asp:Button runat="server" 
      BackColor="Red" 
      ForeColor="White" 
      Font-Name="Arial" 
      Font-Size="9px" />
    
    NoteNote
    A convenient way to create a skin is to add the control to a page and configure it so that it has the look you want. For example, you might add a Calendar control to a page and set its day header, selected date, and other properties. Then, you can copy the control definition from the page to a skin file, and then remove the IDattribute.
  3. Repeat Steps 2 and 3 for each control skin you want to create.
    NoteNote
    You can define only one default skin per control. Use the SkinID attribute in the skin's control declaration to create a named skin that you can apply to specific instances of a control.

Wednesday, 20 February 2013

ASP.NET Website default layout example 1



Layout by Table:
  • Table is comprised by 1 row and 2 Column
    • Left Column is for left menu
      • All the menu is separated by a break line
    • Right Column is for logo & Product pages and they are separated by break line