Friday, January 11, 2019

Checkbox list in ASP.Net MVC



Recently, I got an assignment when I need to show the items in checkbox list format. It was very easy in ASP.NET web form because it has CheckBoxList control but it was bit challenging for me to show the items in checkbox list in ASP.NET MVC as there are basic controls available.

In this post I am going to explain you how to build the CheckBoxList control in ASP.NET MVC using the basic control and Razor engine following the steps listed below. Let’s get started

Step 1. First thing first, View Code

@model SOW.Models.DropdownValues
    <table>
        <tr>
            <td class="td_12per">Select Country:</td>
            <td class="td_12per">
                <div class="divCheckbox" id="divSelCountry">
                    @foreach (var item in Model.SendingCountryList)
                    {
                        <div class="checkbox" style="border:1px solid graymargin-top:-1px;margin-bottom:0px;width:100%;padding-left:2px">
                            <label>
                                <input type="checkbox"
                                       name="SelectedItems"
                                       value="@item.Value" id="SCL_@item.Value" /> @item.Text
                                </label>
                            </div>
                    }
                </div>
            </td>
</tr>
</table>

Step 2. Model
public class DropdownValues
    {
        public DropdownValues()
        {
            CountryList = new List<SelectListItem>();
        }
        public IList<SelectListItem> SendingCountryList { getset; }
    }

Step 3. Controller – Create a controller name CheckboxListController
public class CheckboxListController : Controller
    {
        // GET: AnnualReview
        public ActionResult CheckboxList()
        {
DropdownValues dv = new DropdownValues();
            //Sending Country List
            dv.CountryList.Add(new SelectListItem { Text = "Select All", Value = "SelectAll" });
            dv. CountryList.Add(new SelectListItem { Text = "Australia Australia Australia Australia", Value = "Australia" });
            dv. CountryList.Add(new SelectListItem { Text = "Austria", Value = "Austria" });
return View("ViewName", dv);

        }
}

Step 4. Final Output


Thursday, November 30, 2017

Add Custom Tool under SSIS tool bar


In this post, I am going to explain you how to add the custom task under SSIS tool bar of Microsoft Visual Studio 2012 BIDS.

The first step you need to do is copy all the custom task dll’s under “DTS\Tasks” folder and refresh the SSIS tool bar. If this not bring the custom task under tool bar then you need to use the gacutil to register all the dll’s by running below commands

Gacutil.exe /i

 

Write Unit/Regression test case using Selenium



In this post, I am going to explain you how to automate the testing of web application using the selenium.


There are 2 ways of doing this.
  1. Use Selenium IDE plugin. Only available in Mozilla.
  2. Write the custom test cases using selenium


Let me explain you both the options in detail.


Selenium IDE


                The plugin is available on Mozilla. You can add it and start recording the test cases. It is very simple and easy to understand.




  1. Type in the website URL for which you are recording the test cases.
  2. Click on the RED button on top right of the screen.
  3. Perform the test action on the site. In the background, selenium IDE will record your test and when you complete the test cases, click on the RED button again to stop recording.
  4. You can test the test case by clicking on the “Play” button and you have the leverage to slow and fast the execution of the test case.


Custom Test Case Writing using Selenium


                To write the custom test cases using selenium, you need to build the environment on your machine by installing few dll’s. Details of each dll is provided as below


  1. Selenium Web Driver
  2. Download the browser driver. Use http://www.seleniumhq.org/download/ URL to get the right driver.


Let’s get started


In this example, I am going to use the internet explorer browser to test the test cases. I have downloaded the “IEDriverServer.exe” driver from selenium site and placed on my desktop.
  1. Add new unit test project in Microsoft Visual Studio 2013.
  2. Add “Selenium WebDriver” using NuGet package.
  3. In your unit test class, add the following namespaces
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Firefox;


      4. Declare a webdriver variable and create the object.


static IWebDriver driverIE;
 
                [TestInitialize]
public void Initilization()
{
            driverIE = new InternetExplorerDriver(@"C:\Users\UserName\Desktop");
}


      5. Write your first test case. Here I am writing the test case for the login


     [TestMethod]
            public void TestMethodIELogin()
            {       
                                 driverIE.Url = "http://localhost:8181/web pages/login.aspx";
                                 driverIE.FindElement(By.Id("txtUserName")).SendKeys("UserName");
                                 driverIE.FindElement(By.Id("txtPwd")).SendKeys("test123");
                                 driverIE.FindElement(By.Id("btnLogin")).SendKeys(Keys.Enter);
            }


      6. Run the test case by pressing the Ctrl+R+T or you can just right click on any test case and select “Run Tests”

Sunday, December 13, 2009

How To Use DES Encryption

DES (Data Encryption Standard) is a very good and easy encryption method in the new world. Using DES you protect the data on web sites.If you need to share the data on internet and you want no body can misuse that data for that you need to use a encryption technique and DES is one of them. If you want to learn more about DES Click Me

How To Use TripleDES (3DES)

Guys if you need to know how to use Triple-DES (3DES) for securing your data. Click Me