Random Notes and simple code on Developing Web Sites (Applications) in ASP.net using C# #.Net Web Applications

Brought from: http://salearningschool.com/displayArticle.php?table=Articles&articleID=1319&title=Random%20Notes%20and%20simple%20code%20on%20Developing%20Web%20Sites%20(Applications)%20in%20ASP.net%20using%20C#

And sure, pretty old article..

Random Notes and simple code on Developing Web Sites (Applications) in ASP.net using C#

  • The information below primarily apply to the web page model of web-development in C#
  • _PageStart.cshtml runs at each page start/open
  • _AppStart.cshtml runs at the beginning of the application
  • Syntax to use the Layout file: @{Layout = “/Shared/Layout.cshtml”;}
  • if you use this – @{Layout = /Shared/Layout.cshtml”;} in the _PageStart.cshtml file, you will not need to use it at the top of each file
  • You can use Microsoft Webmatrix, Visual Web Developer, or Visual Studio for web development
  • Webmatrix, includes IIS Express, and also a database workspace where you can create and use compact SQL Server Databases
  • DateTime.Now : will display current date and time
  • You can connect to a database using var db = Database.Open(“db_name”);
  • db = Database.Open(“db_name”); will look for the database in the same workspace; if not found will use the connection parameter as defined in the web.config file to find and connect to database
  • Executing a query: var queryString = “SELECT * FROM Product ORDER BY Name”; db.Query(queryString)
  • Accessing each row from a rowset of data as returned from database:
                   
    foreach(var entry in db.Query((queryString))) {
       @entry.Id, @entry.Name
    }
    
  • if (IsPost) : will check if a form is submitted by POST or not
  • username = Request.Form[“username”]; Will retrieve username from the Request object [submitted form with control named username]
  • A basic login authentication code can be as follows
       
            var username = "";
            var password = "";
            var ErrorMessage = "";
            
            // If this is a POST request, validate and process data
            if (IsPost){
                
                username = Request.Form["username"];
                password = Request.Form["password"];
                
                if (username.IsEmpty() || password.IsEmpty()){
                    ErrorMessage = "You must specify a username and password.";
                }else{
                    // Login, Navigate back to the homepage and exit
                    if (WebSecurity.Login(username, password, false)){
                        Response.Redirect("~/");
                    }
                    else{
                        ErrorMessage = "Login failed";
                    }
                }
            }
                            
            @if (ErrorMessage!="") {
                @ErrorMessage, Please correct the errors and try again.
            }
    
        
  • Execute an Insert Statement: db.Execute(“INSERT INTO UserProfile (Email) VALUES (@0)”, email);
  • WebSecurity object can be used for the security of your web-site (application) such as user authentication, block a page until a user is authenticated
  • Block user if he is not logged in [can be added at the top of the page to be blocked]
               
                          @{
                if (!WebSecurity.IsAuthenticated) Response.Redirect("~/Login"); //redirect to login page
                }
            
  • WebSecurity.InitializeDatabaseConnection(“db_name”, “profile_of_the_users_table”, “UserId”, “Email”, true);
  • WebSecurity.CreateAccount(email, password, false);

From: http://sitestree.com/?p=3718
Categories:.Net Web Applications
Tags:
Post Data:2016-07-16 10:38:29

    Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
    (Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a> 
    In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
    <a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
    8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
    Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
    Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>

Formatting Web-application output #.Net Web Applications

Brought from: http://salearningschool.com/displayArticle.php?table=Articles&articleID=1144&title=Formatting%20Web-application%20output

  • You can apply CSS styles to format web-application output
  • If you have the same styles defined in multiple places (for the same element), the styles defined closest to the element will be applied. The order, inline, page, global (however, you should not define the same class here and there arbitrarily…that is an another topic)
  • You can create classes that can be applied to multiple elements
  • Use the CssStyle/CssStyle attribute to apply a style class to a server control
  • use the class attribute to apply a style class to an HTML element
  • Yes, you need to create a style file, and link to it from your web-form
  • You can click the style property of an element or the style property/attribute of the form to bring the Style Wizard to define/modify existing styles
  • You can also use the ‘Add Style Rule’ option in the popup menu on the .css files to define new styles. Also, use the ‘Synchronize Document Elements’ from the popup menu if required

From: http://sitestree.com/?p=3712
Categories:.Net Web Applications
Tags:
Post Data:2016-07-16 14:48:04

    Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
    (Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a> 
    In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
    <a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
    8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
    Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
    Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>

Providing Help in an ASP.Net Web-application #.Net Web Applications

Brought from: http://salearningschool.com/displayArticle.php?table=Articles&articleID=1124&title=Providing%20Help%20in%20an%20ASP.Net%20Web-application

  • Use the Tooltip attribute of the ASP.Net controls to display help in Tooltip text
  • You can create HTML pages to provide/show help. Just as a simple web-page
  • You can use Web Forms to display help information
  • You can display help using HTML Help Viewer
  • You can use the HTML Help Workshop as comes with the Visual Studio to create Help projects similar to the generic windows help. Use the workshop and create a help project. Compile the help project into one .chm file. Use the ShowHelp method of the Window object to open this file (as a help file). Such help files usually have three tabs such as Contents, Index, and Search.

From: http://sitestree.com/?p=3710
Categories:.Net Web Applications
Tags:
Post Data:2016-07-16 10:20:24

    Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
    (Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a> 
    In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
    <a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
    8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
    Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
    Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>

.Net: Globalizing Web Applications #.Net Web Applications

Brought from: http://salearningschool.com/displayArticle.php?table=Articles&articleID=1145&title=.Net:%20Globalizing%20Web%20Applications

Three ways of globalizing web-applications

  • Create one for each culture/language – usually the web-interfaces. Redirect to a web-site built based on the current culture
  • Write one web-application but detect current culture, then change the user interface (texts, date time formats) to represent the current culture – dynamically
  • Satellite Based: Use resource files to keep culture specific messages. One resource file for one culture. Resource files will be in the format: key = value/message. Use the keys in the user interfaces. The keys will be replaced with the messages/values as stored in the resource files – based on current culture.
  • Best Approach: Satellite Based
  • Current culture: as set in the browsers/operating systems – or give culture/language change option on a button click
  • How to detect current culture: Use CultureInfo, Calendar, and comparison classes
  • Setting culture in the web.config file: Use the globalization element of the web.config file. You can set properties for each culture
  • Satellite Based
    • set the id and runat attributes for all the user-interface elements that require translation
    • create a fallback resource file to keep default strings (key=value) (displays by default or no culture is set or culture is not recognized)
    • create resource file for each culture that you want to support
    • Use the ResourceManager class to load the resource files
    • write code to detect the user’s current culture.
    • Write code to load strings from the resource files and display them
    • Example:
        using System.Globalization
        using System.Threading
        using System.Resources
      
      protected ResourceManager gStrings = 
         new ResourceManager( "JustEtcWebAppsCS.strings", typeof(Satellite).Assembly);
      
      ..
      ..
      ..
      
      head1.InnerHtml = gStrings.GetString("satellite.head1");
      

From: http://sitestree.com/?p=3706
Categories:.Net Web Applications
Tags:
Post Data:2016-07-16 09:15:49

    Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
    (Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a> 
    In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
    <a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
    8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
    Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
    Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>

JQuery & ASP.Net #.Net Web Applications

Brought from: http://salearningschool.com/displayArticle.php?table=Articles&articleID=1090&title=JQuery%20&%20ASP.Net

Watch the following videos. Then read a book on ASP.Net & jQuery (may be from Apress), sure, practice the examples, and then consult a good reference book, keep in touch with jQuery online site esp. with references and new changes.

From: http://sitestree.com/?p=3703
Categories:.Net Web Applications
Tags:
Post Data:2016-07-16 09:09:32

    Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
    (Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a> 
    In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
    <a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
    8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
    Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
    Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>

nHibernate & ADO.net entity Framework #.Net Web Applications

Brought from: http://salearningschool.com/displayArticle.php?table=Articles&articleID=988&title=nHibernate%20&%20ADO.net%20entity%20Framework

This was written long long back, hence, the resources linked are also pretty old.

From: http://sitestree.com/?p=3701
Categories:.Net Web Applications
Tags:
Post Data:2016-07-16 09:01:03

    Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
    (Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a> 
    In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
    <a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
    8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
    Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
    Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>

How to Build a Personal Web-site with ASP.Net #.Net Web Applications

Brought and updated from: http://salearningschool.com/displayArticle.php?table=Articles&articleID=967&title=How%20to%20Build%20a%20Personal%20Web-site%20with%20ASP.Net%20(VS%202008,%20.Net%202.0/3.5)

This actually is an old way of doing.

  1. Video Tutorial on this topic
    [youtube https://www.youtube.com/watch?v=PmWqWvaelyg]
  2. Web-site Code used in this tutorial
  3. Steps
    • Open visual studio (2008) IDE
    • File -> new project -> Visual Basic -> Web -> ASP .Net Web Application
    • Rename default.aspx to template.aspx
    • Insert a table from the tool box
    • Create three rows for the table: top, body, bottom
    • Top Row: banner, slogan
    • Body Row: three cell: left, right, middle: left for left menu, right for right menu/advertising code, middle for contents
    • bottom: privacy, copyright, links to contact us
    • Keep left menu, right menu, top banner, bottom/footer contents in separate files such as leftMenu.aspx, rightMenu.aspx, topBanner.aspx
    • In the template.aspx use Response.WriteFile(“file.aspx”) to link to the left and right menu, the top banner, the bottom/footer. Change file.aspx to the right file name.
    • Create the leftMenu.aspx, rightMenu.aspx, topBanner.aspx, bottom.aspx
    • template.aspx is just the template file. We have two options in the left menu like Home and Companies, that point to index.aspx, and companies.aspx respectively. You have to create those files
    • Now copy the template file, paste it, rename it to index.aspx. index.aspx will be the root file of your web-site. Change the body part of the index.aspx to add contents
    • Copy the template.aspx file, paste it, rename it to companies.aspx. Change the body part of companies.aspx to add contents
    • You can modify leftMenu.aspx to add more options in the left menu. For each option that links to a .aspx file you have to create the .aspx file using the template.aspx [unless already existing]
    • Similarly, you can change your right menu contents by updating rightMenu.aspx
  4. Deployment:
    • Can copy the aspx files in the right place under IIS
    • or let VS 2008 to deploy – right click the project in the solution explorer, click on publish, select the path where you want to publish the website, publish it to a folder where IIS has access
    • You may need to configure IIS a bit, create/identify this application as a .Net application. Otherwise, it may not work. Else, you can adjust/edit the files to make them work [remove some lines].
    • Test the application

From: http://sitestree.com/?p=3699
Categories:.Net Web Applications
Tags:
Post Data:2016-07-16 08:49:36

    Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
    (Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a> 
    In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
    <a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
    8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
    Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
    Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>

What is Silverlight? #.Net Web Applications

Brought From our old site: http://salearningschool.com/displayArticle.php?table=Articles&articleID=899&title=What%20is%20silverlight?

Quick Facts

  • It’s by Microsoft for Rich Internet Application Development
  • Supports high quality graphics/animations
  • Runs in Windows, Mac, Linux
  • From PHP, you can also make use of Silverlight
  • Offers copy protection
  • Related technologies: Adobe Flash, Java FX
  • Debugging is possible from Visual Studio IDE
  • Supports IE, Firefox, Opera, Safari
  • The claim is: it’s significantly fast
  • Supports progressive download and play
  • What is Silverlight
  • Silverlight Tutorial: Creating an Animated Navigation Bar with Silverlight

From: http://sitestree.com/?p=3695
Categories:.Net Web Applications
Tags:
Post Data:2016-07-16 08:34:45

    Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
    (Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a> 
    In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
    <a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
    8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
    Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
    Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>

ASP.Net Controls #.Net Web Applications

Brought from: http://salearningschool.com/displayArticle.php?table=Articles&articleID=746&title=ASP.Net%20Controls

 

HTML Server Controls
HtmlAnchor
HtmlButton
HtmlForm
HtmlGeneric

HtmlImage
HtmlInputButton
HtmlInputCheckBox
HtmlInputFile
HtmlInputHidden
HtmlInputImage
HtmlInputRadioButton
HtmlInputText
HtmlSelect
HtmlTable
HtmlTableCell
HtmlTableRow
HtmlTextArea

Web Server Controls
AdRotator
Button
Calendar
CalendarDay
CheckBox
CheckBoxList
DataGrid
DataList
DropDownList
HyperLink
Image
ImageButton
Label
LinkButton
ListBox
ListItem
Literal
Panel
PlaceHolder
RadioButton
RadioButtonList
BulletedList
Repeater
Style
Table
TableCell
TableRow
TextBox
Xml

Validation Server Controls
CompareValidator
CustomValidator
RangeValidator
RegularExpressionValidator
RequiredFieldValidator
ValidationSummary From: http://sitestree.com/?p=3693
Categories:.Net Web Applications
Tags:
Post Data:2016-07-16 08:19:37

    Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
    (Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a> 
    In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
    <a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
    8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
    Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
    Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>

ASP.Net Controls #.Net Web Applications

HTML Server Controls
HtmlAnchor
HtmlButton
HtmlForm
HtmlGeneric<br/>
HtmlImage
HtmlInputButton
HtmlInputCheckBox
HtmlInputFile
HtmlInputHidden
HtmlInputImage
HtmlInputRadioButton
HtmlInputText
HtmlSelect
HtmlTable
HtmlTableCell
HtmlTableRow
HtmlTextArea

Web Server Controls
AdRotator
Button
Calendar
CalendarDay
CheckBox
CheckBoxList
DataGrid
DataList
DropDownList
HyperLink
Image
ImageButton
Label
LinkButton
ListBox
ListItem
Literal
Panel
PlaceHolder
RadioButton
RadioButtonList
BulletedList
Repeater
Style
Table
TableCell
TableRow
TextBox
Xml

 

Validation Server Controls
CompareValidator
CustomValidator
RangeValidator
RegularExpressionValidator
RequiredFieldValidator
ValidationSummary From: http://sitestree.com/?p=3459
Categories:.Net Web Applications
Tags:
Post Data:2016-07-09 20:29:28

    Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
    (Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a> 
    In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
    <a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
    8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
    Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
    Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>