Skip to main content

Posts

Showing posts from July, 2014

Featured Post

How to use Tabs in ASP.NET CORE

I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component  public class AllViewComponent : ViewComponent     {         private readonly UserManager<ApplicationUser> _userManager;         public AllViewComponent(UserManager<ApplicationUser> userManager)         {             _userManager = userManager;         }         public async Task<IViewComponentResult> InvokeAsync()         {             List<StudentViewModel> allUsers = new List<StudentViewModel>();             var items = await _userManager.Users.ToListAsync();             foreach (var item in items)             {                 allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email });             }            

How to add item into the listBox in windows phone

ListBox is a container in which we can add strings. User can select by clicking. Article contain different topics , these are  1. Add ListBox Control with items using XAML  2. Add ListBox Control in code file There are some basic steps to complete that tasks Add ListBox control with items using XAML Step-1 :  Add ListBox control in contentPanel using xaml code , now your code llok like <ListBox x:Name=" ListBox1" >  </ListBox> Step-2 :  Open ListBox properties and select Items(collection) ellipse symbol. After pressing ellipse button , A new window will appear Step-3 :  Using Object Collection Editor, add controls to the List Box by selecting controls from Dropdown List. Step-4  : After adding controls, you can assign content property of them. Step-5 : Now, Press Ok button after adding items. Step-6 : Now , Your complete code look like <ListBox x:Name=" L1" >                 <ListBoxItem Content="Apple"

Getting started with windows phone App C#

Now start code with windows phone, first to develop app in windows phone. Get the tool you need, build your first app and test it in your system simulator. you can run this in your phone also. Before learning this article, must to learn XAML syntax. After that you can easily transfer your skills to develop windows phone app that use xaml for the UI and c#.    This topic contains the following sections . Get set up Create your first app Get set up Download the Windows Phone SDK 8.0 , which includes all the tools you need to create Windows Phone apps: Microsoft Visual Studio Express 2012 for Windows Phone, project templates for creating new Windows Phone apps, the Windows Phone emulator for testing, and more. Create your first app he first step in creating a Windows Phone app is to create a new project in Visual Studio. To create the project Make sure you’ve downloaded and installed the Windows Phone SDK.  Launch Visual Studio from the Windows Start screen. If

How to Submit data on DropDown Selection changed in MVC Razor

Submitting the form by button, programmer have to assign only the type of that button and on click this button all the data can be get on the server side. On drop-down change we have manually submit the form by either specifying "OnSelectionChanged" event or some jquery functions. In earlier article I have created DropDownList in MVC , to submit the form we can simply use only submit function on change event of the list. @Html.DropDownList("ddlname", "List to bind", "--default title--", new { onchange = "submit();" }) After writing this code on change it will post all the data on the form to server-side but programmer have to use same name in action method as used here “ddlname”. When we use view-model to bind the data then dropdown list’s code will be changed as: @Html.DropDownListFor(model => model.Property , "List to bind", "--default title--", new { onchange = "submit();" }) This code will

How to Use Multiple Submit Button in MVC Razor

The most common method to get the data on server from client side. Submit button on the form can be used to post all the form data to be used further by programmer. Generally one form only have a single submit because of user want to post data only once. To submit data in different ways programmer can use more than one submit button. A form can have multiple submit buttons as per the requirement of programmer. We can send the button’s name on the button click. The action should have the same name of the button to get the value of clicked button. Suppose all the button’s have same name as submit as written below: <input type = "submit" name = "btnsubmit" value= "submit1" /> <input type = "submit" name = "btnsubmit" value= "submit2" /> <input type = "submit" name = "btnsubmit" value= "submit3" /> Now in controller’s action the variable should be of string type and name a

How to add Hyperlink button control by using code in windows phone

In previous article we have already learned about   Hyperlink Button control .  Using the HyperlinkButton control you can navigate one page to another in windows phone. The following example creates a HyperlinkButton control named hyper and then adds it to ContentPanel grid. To add the Hyperlink Button control by using code Open MainPage.xaml.cs. Add the following code in the constructor. C# public MainPage()         {             InitializeComponent();             HyperlinkButton h1 = new HyperlinkButton();             h1.Content = "My Button";             ContentPanel.Children.Add(h1);             h1.Click += new RoutedEventHandler(HyperlinkButton_Click);             // Sample code to localize the ApplicationBar             //BuildLocalizedApplicationBar();         }  private void HyperlinkButton_Click(object sender, EventArgs e)         {             NavigationService.Navigate(new Uri("/secondpage.xaml", UriKind.Relative));      

How to add a Hyperlink Button control to a page in Windows Phone 8

This topic describes the various ways to add a Hyperlink Button control to a Windows Phone 8 project. The Hyperlink Button control is part of the libraries in Windows Phone SDK 8.0. This topic contains the following sections. Adding a Hyperlink Button control by using the Toolbox. Adding the Hyperlink Button control by using XAML. Adding the Hyperlink Button control by using code . Adding a Hyperlink Button control by using the Toolbox The easiest way to add a Hyperlink Button control and reference it properly is to drag it from the Toolbox and drop it to your XAML designer or XAML view. To add a Hyperlink Button control from the Toolbox In the HyperlinkApplication project, open the Toolbox, and then open the All Windows Phone Controls. From the Toolbox, drag the HyperlinkButton control to the XAML or designer view.Visual Studio performs the following tasks automatically. In the <phone:PhoneApplicationPage> start tag of the XAML page. Adds the followin

How to get back date from current date in ASP.NET C#

If you want to find back date from current date then you should take DateTime Structure with add days method. Through this method we can add some days in existing date. But if we pass minus sign(-) with integer value  in add days method then you get back date. lets take a simple example. Complete Code <%@ Page Language="C#" %> <!DOCTYPE html> <script runat="server">     protected void Button1_Click(object sender, EventArgs e)     {         DateTime currentdate = DateTime.Now;         Label1.Text = currentdate.ToString()+"<br/>";         Label1.Text += "before 3 days " + currentdate.AddDays(-3);     } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title>Get back Date</title> </head> <body>     <form id="form1" runat="server">   <div>         <asp:Label ID="Label1&qu

How to Perform Searching Data by Using a Full-Text Search

After the full-text index has been created on a table, you can query the table by using the full-text predicates. The full-text predicates are used to specify how the search string should be searched in the table. Predicates can be used to enhance the search so that the result have so focus on the search criteria. Sql programming have a list of predicates to be used. The following predicates can be used while performing the full-text search: FREETEXT: When the search criteria are given, FREETEXT searches for any variation of a word or a group of words given in the search column. FREETEXT is used for the prefix searches. Considering the previous scenario of the bike racing competition, you can use the FREETEXT predicate to obtain the desired output, as shown in the following statement: SELECT Description FROM Production.ProductDescription WHERE FREETEXT (Description, ‘race winners’) CONTAINS: This predicate is used in queries when you want to search for a specific phrase or

Populating the Full-Text Index in Search: SQL Server

After creating the full-text index, you need to populate it with the data in the columns enabled for full-text support. The SQL Server full-text search engine populates the full-text index through a process called population. Population involves filling the index with words and their location in the data page. When a full-text index is created, it is populated by default. In addition, the SQL Server automatically updates the full-text index as the data is modified in the associated tables. However, the SQL Server does not keep a list of changes made to the indexed data when the CHANGE_TRACKING option is off. This option is specified while creating the full-text index by using the CREATE FULLTEXT INDEX statement. If you do not want the full-text index to be populated when it is created using the CREATE FULLTEXT INDEX statement, then you must specify NO POPULATION along with the CHANGE TRACKING OFF option. To populate the index, you need to execute the ALTER FULLTEXT INDEX comma

Configuring Full-Text Search in SQL Server

The full-text query feature in the SQL Server enables users to search for a wide range of text in the SQL tables. Consider an example. The sales management team of AdventureWorks, Inc. makes frequent searches on the ProductDescription table to develop marketing strategies. The search is based on the data stored in the Description column of the table. A bike racing competition is scheduled to begin in Texas. The sales manager of AdventureWorks wants to see the details of all the bikes that are related to racing, so that a marketing strategy can be designed to increase the sale of these bikes. Specifically, he wants a list of all the bikes that have the keyword ‘race winner’ in the description. As the data is large, the search query takes a long time to retrieve data from the table. In this scenario, you can apply a full-text index on the Description column of the ProductDescription table to improve the speed of searching. To retrieve the required details by using full-text search

Altering, Dropping and Renaming Views in SQL Server

In addition to creating view in sql server, database developer also need to manage them. Management of a view includes altering, dropping, or renaming described below. Altering views If you define a view with a SELECT * statement and then alter the structure of the underlying tables by adding columns, the new columns do not appear in the view. Similarly, when you select all the columns in a CREATE VIEW statement, the columns list is interpreted only when you first create the view. To add new columns in the view, you must alter the view. You can modify a view without dropping it. This ensures that permissions on the view are not lost. You can modify a view without affecting its dependent objects. To modify a view, you need to use the ALTER VIEW statement. The syntax of the ALTER VIEW statement is: ALTER VIEW view_name [ (column_name) ] [WITH ENCRYPTION] AS select_statement [WITH CHECK OPTION] Where, View_name specifies the view to be altered. Column_name specifies the n

How to Implement Custom Role Provider in Asp.Net MVC

As I have discussed in earlier article that programmer need to implement custom provides to enable its own database works with in-built functionality. My previous article was to implement custom membership provider and in this article I will continue with custom role provider in MVC. By following these simple steps we will complete the task: Create a class "Custom_RoleMembership" in Models folder in your MVC application. Inherit this from RoleProvider class exists in "System.Web.Security" namespace. Right click on RoleProvider and select on “Implement Abstract Class”, it will all the override function need to be implement by us. Just implement GetRolesForUser(string username) method and replace that function with the following code: public override string[] GetRolesForUser(string username) { //Get roles for this username and return in string array if(username=="admin") return new string[] { "Admin" }; return null; } Go to Ho

How to Implement Custom Membership in Asp.Net MVC

In Asp.Net MVC, default membership works with pre-defined/specified data source where programmer don’t worry about anything related to authentication. To implement authentication with desired data source, programmer must implement custom membership as explained in the article. Using custom membership, programmer can easily authenticate user’s visit through self-written code. This article will describe some simple steps to complete the task: Create a class named "Custom_Membership" in Models folder in your MVC application. Inherit this from MembershipProvider class exists in “System.Web.Security” namespace. Right click on MembershipProvider and select on “Implement Abstract Class”, it will all the override function need to be implement by us. Just implement ValidateUser() method and replace that function with the following code: public override bool ValidateUser (string username, string password) { if (username == " admin " && password == " pas

How to change text color from ARGB value in ASP.NET

ARGB( ) takes four integer input parameter as a argument. Method name explain all things automatically. This name contain four color code, first "A" for Alpha which take 0-255 integer value. Similarly "R" for RED , "G" for Green and "B" for blue. Now lets take an simple example of ARGB( ) method. Source code <form id="form1" runat="server">     <div>              Enter Alpha Color code :         <asp:TextBox ID="TextBox1" runat="server" Width="190px"></asp:TextBox>         <br />         Enter Red Color Code&nbsp;&nbsp;&nbsp; :<asp:TextBox ID="TextBox2" runat="server" Width="190px"></asp:TextBox>         <br />         Enter Green Color Code:<asp:TextBox ID="TextBox3" runat="server" Width="190px"></asp:TextBox>         <br />         Enter Blue Col

How to Bind Radio Button Control inside the Grid View control in ASP.NET

Binding process of control is same , You can bind all of controls from this method. In previous article we have  already discussed about Bind GridView in asp.net . In this example we have four radio buttons and one label control. Bind the text  of  radio button use <%# Eval(" Attribute of table") %> . <asp:GridView ID="GridView2" runat="server" Height="202px" Width="624px" AutoGenerateColumns ="False" ShowHeader="False" AllowPaging="True">       <Columns> <asp:TemplateField>     <ItemTemplate>         <asp:Label ID="Label1" runat="server" Text='<%# Eval("Question") %>'></asp:Label><br />                   <asp:RadioButton ID="R1" runat="server" Text ='<%# Eval ("Answer-1") %>' GroupName ="g1" />          <asp:RadioButton ID="R2" run

Clock in windows phone 8

In this article,  i will use  DispatcherTimer class for creating timer control. Using interval property of this class, i will set the increment counter. After set the interval you can call tick event of this class. On tick event you can take current date and time. . To create a new app in windows phone 8, the steps are listed below: Create a new project by going through File | New Project | Windows Phone Application - Visual C#. Give a desired project name( World Clock is my app name). From Solution Explorer, open MainPage.xaml file. (If Solution Explorer window is currently not opened then open it via View>>Other Windows>>Solution Explorer). Inside Control Panel code fragment, add following code to create world clock app. Source code (MainPage.xaml)  <TextBlock HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="436" Height="63" x:

How to Get text of radio button using JQuery

If you want to get Text from radio button then first to determine whether the radio button is checked or not , if it is checked then return true. Using the name property, you will get element of  html control. ':Checked' property check the status of html control. Suppose your radio button return true (it means checked) then you will get the value of radio button control using the val( ) method. Now lets take an simple example <%@ Page Language="c#" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">        <title>Get Text Of Radio Button</title>     <script src="Scripts/jquery-1.10.2.js"></script>     <script>         $(function () {             $('#Button1').click(function () {                 var rdtxt = $('input[name=rd]:Checked').val();                 alert(rdtxt);             })         });  </script> &

How to check RadioButton or CheckBox is checked or not using JQuery

Welcome to JQuery, using ID property of HTML element you can get attribute of element in JQuery. If you want to get any element in JQuery, Should create a function in <Script> </Script> block, now your code look like. <script type="text/javaScript"> $(function( ) { } ); </Script> Now, if you want to handle function on button_click event then you must retrieve button_id using '#' after that you will handle any event on it like click. Today we will learn , how to check status of control like checked or not, first to get id of that control. Also check it using this function is(':checked') Note :  Must add     <script src="Scripts/jquery-1.10.2.js"></script> in your head section of page . I have visual studio 2013 so i use 1.10.2. You can also use 1.8.2.js file  Now your complete code is  <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inher

How to send bulk email in asp.net

If you want to send email in bulk then you should go for my algorithm. I have already learn about SMTP services ( how to to send e-mail ). Today we will learn , how to send email in bulk. There are various steps to send email in bulk, these are 1. Bind proper information of customer in gridview ( learn how to bind gridview in asp.net ) 2. Make user friendly application, in which you can insert data in gridview at runtime.( How to insert data into database ) 3. Take two textboxes on design window for email-subject and email-message. 4. Also add single button control for sending message. 5. Raise click_event for button control. 6. Run foreach loop for all rows of gridview like foreach (GridViewRow  gdata in GridView1 .Rows)         { } 7. Extract e-mail field from gridview, now, your code look like.  string email = gdata.Cells[3].Text.Trim(); 8. After retrieving single address from gridview, now you can send message. 9. Run your application. Complete code u

If statement in c#

Its also known as conditional statement, in c# there are two types of conditional statements. First one is if statement and second one is switch statement. In this article we will learn about if statement, basically if statement depends on condition. If your statement condition is true then if statement is executed otherwise not. Lets take an simple example Suppose you have a variable  a of type int with having some value (take from user input). Like int a= int.Parse(Console.ReadLine()); Now, if you want to compare this value from other value like 10. Now your statement look like if(a==10) {    Console.writeLine("Your Number is 10"); } So lets analyze this code, Now start from if statement , if statement needs a Boolean expression. In this code , evaluate the expression, which is inside in if bracket. Also return true as well as false Boolean value. If code return true then execute if block. Similarly we create multiple if block like if(a==10) {    Console.writ