June 2012 | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more

Solution:ASP.NET: Unable to find the requested .Net Framework Data Provider. It may not be installed. - MVC3/MVC4 application with visual studio 2010


ASP.NET MVC 3 - Unable to find the requested .Net Framework Data Provider:
                                             I getting "Unable to find the requested .Net Framework Data Provider" when trying to setup a new data-source in Visual Studio 2010 ultimate for my first MVC 4 application.

  I'm trying to following exactly the steps from the "Intro to ASP.NET MVC 4"-tutorial and I'm running into a problem at the first step from part 5 - Accessing Your Model's Data from a Controller ( Adding the MoviesController). When I'm trying to add the "MoviesController" with the exact settings that are shown in the tutorial and click 'Add' I get this error.

          There is lots of results when searching for the phrase "Unable to find the requested .Net Framework Data Provider". But most of the suggestions/ solutions not work for me.
And finally Microsoft SQL Server Compact 4.0 solved my problem.


I installed Microsoft SQL Server Compact 4.0, and that fixed the problem for me.

If this post was help to you. Then Share this to your friends. Thanks!

iphone - create .ipa file in Xcode 4.3


How to create .ipa file for your iPhone app : xcode build and archive:
                                                                                     In this article I'm going to explain how to create .ipa file in Xcode 4.3 for your iPhone apps?. Each .ipa file is compressed with a binary for the ARM architecture that can only be installed on iOS devices. If you change the extension to .zip you will be able to unzip it and view the contents.

What is .ipa file (iOS App Store Package file)?
             An .ipa file is an iPhone application archive file which stores an iPhone app. It is usually encrypted with Apple's FairPlay DRM technology. Each .ipa file is compressed with a binary for the ARM architecture and can only be installed on an iPhone, iPod Touch, or iPad. Files with the .ipa extension can be uncompressed by changing the extension to .zip and unzipping.
            .ipa files cannot be installed on the iPhone Simulator because they do not contain a binary for the x86 architecture. To run applications on the simulator, original project files which can be opened using the Xcode SDK are required.

How to create IPA file ? - iPhone:
                         To create .ipa file in your xcode, you can  follow the steps below . Before going to create .ipa file you must build your iPhone app without any errors.

Step 1:  After build your iphone app click Archive option under product menu. ( Note: The Archive option become enable, once you connect your iPhone  with your system)

Step 2:  Then open organizer and  choose your project (from the left panel) under Archives window then click Distribute.

Step 3:  Click Distribute and select  "Save for Enterprise or Ad-Hoc Deployment" option under select the method of distribution. Then click next button.

Step 4:  After select distribution method you have to add your iphone developer profile certificate  . Here you can use your existing profile or you can import  a new developer profile.

Step 5:  After complete your code signing identity click next button then  the .ipa file is automatically created and you can save it in your system.

Now your app ready to install to your IOS based devices.

If this post was help to you. Then Share this to your friends. Thanks!

ASP.NET:How to upgrade an MVC project from MVC2 to MVC3

Upgrading an ASP.NET MVC 2 Project to ASP.NET MVC 3 Tools Update:
                                                                       ASP.NET MVC 3 can be installed side by side with ASP.NET MVC 2 on the same computer, which gives you flexibility in choosing when to upgrade an ASP.NET MVC 2 application to ASP.NET MVC 3.
To manually upgrade an existing ASP.NET MVC 2 application to version 3, do the following:
  1. Create a new empty ASP.NET MVC 3 project on your computer. This project will contain some files that are required for the upgrade.
  2. Copy the following files from the ASP.NET MVC 3 project into the corresponding location of your ASP.NET MVC 2 project. You'll need to update any references to the jQuery library to account for the new filename ( jQuery-1.5.1.js):
    • /Views/Web.config
    • /packages.config
    • /scripts/*.js
    • /Content/themes/*.*
  3. Copy the packages folder in the root of the empty ASP.NET MVC 3 project solution into the root of your solution, which is in the directory where the solution’s .sln file is located.
  4. If your ASP.NET MVC 2 project contains any areas, copy the /Views/Web.config file to the Viewsfolder of each area.
  5. In both Web.config files in the ASP.NET MVC 2 project, globally search and replace the ASP.NET MVC version. Find the following:

    System.Web.Mvc, Version=

    Replace it with the following:

    System.Web.Mvc, Version=
  6. In Solution Explorer, delete the reference to System.Web.Mvc (which points to the DLL from version 2), then add a reference to System.Web.Mvc (v3.0.0.0).
  7. Add a reference to System.Web.WebPages.dll and System.Web.Helpers.dll. These assemblies are located in the following folders:
    • %ProgramFiles%\ Microsoft ASP.NET\ASP.NET MVC 3\Assemblies
    • %ProgramFiles%\ Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies
  8. In Solution Explorer, right-click the project name and select Unload Project. Then right-click the project name again and select Edit ProjectName.csproj.
  9. Locate the ProjectTypeGuids element and replace {F85E285D-A4E0-4152-9332-AB1D724D3325} with {E53F8FEA-EAE0-44A6-8774-FFD645390401}.
  10. Save the changes, right-click the project, and then select Reload Project.
  11. In the application’s root Web.config file, add the following settings to the assemblies section.
<add assembly="System.Web.WebPages, Version=, Culture=neutral, 
                   PublicKeyToken=31BF3856AD364E35" />
                   <add assembly="System.Web.Helpers, Version=, Culture=neutral,
                         PublicKeyToken=31BF3856AD364E35" />

   12. If the project references any third-party libraries that are compiled using ASP.NET MVC 2, add the following highlighted bindingRedirect element to the Web.config file in the application root under the configuration section:
                       <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                         <assemblyIdentity name="System.Web.Mvc"
                          <bindingRedirect oldVersion="" newVersion=""/>

More about ASP.NET MVC 3

If this post was help to you. Then Share this to your friends. Thanks!

Source code: Create Dynamic LinkButton and Click event for dynamic linkbuttons in asp.net


ASP.NET Dynamic LinkButton  using c#(Create dynamic html table in asp.net):
                                          In this article I am explaining how to add Dynamic table with Dynamic LinkButton. In the design page, we just add how many controls we need and where it should be placed. These controls are static and having the data what we gave. In some cases we have to dynamically get data from the database and create dynamic controls for the data.

      Creating Dynamic LinkButton in Asp.Net is simple one . After creating the dynamic controls just add the controls in a PlaceHolder or Panel control.

       In the following sample, I'm created a html table with students name  at run time. Here i'm created dynamic link for all students at the time of binding. The dynamic click event "lnkStudentDetails_Click" redirect to corresponding student details page.

       In the Page_Load event, Call the load data method outside the IsPostBack() method. Because our dynamic controls should recreate each and every time when a postback call.

"C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Coding Cluster - Dynamic Link Button</title>
<form runat="server" id="f1">
    <asp:Panel ID="pnlStudentDynamic" runat="server">



using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
    // Create object for your html table
    HtmlTable tblStudents = new HtmlTable();

    protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
            //Do nothing
       //Load students name

    public void LoadStudents()
       // Connection string for your database
        SqlConnection SqlConn = new SqlConnection("Data Source=localhost;Initial Catalog=Student;User ID=sa;Password=sa");
        SqlDataAdapter SqlDap = new SqlDataAdapter("select * from StudentMaster", SqlConn);
        DataTable objDT = new DataTable();

        tblStudents.ID = "tblStudent";
        tblStudents.Width = "40%";
        tblStudents.CellPadding = 5;
        int intRowCount = objDT.Rows.Count;

        if ((intRowCount > 0))
            int sCount = (intRowCount / 2) + 1;
            int intCurrentCount = 0;
            for (int i = 1; i <= sCount; i++)
                HtmlTableRow tblRowDef = new HtmlTableRow(); tblRowDef.Align = "center"; if ((intRowCount > intCurrentCount))
                    for (int l = 1; l <= 2; l++)
                        if ((intRowCount > intCurrentCount))
                            HtmlTableCell tblCellDef = new HtmlTableCell();
                            tblCellDef.ID = "0" + objDT.Rows[intCurrentCount]["Student_Name"].ToString();
                            tblCellDef.Width = "50px";
                            LinkButton lnkStudent = new LinkButton();
                            lnkStudent.ID = "lnkStudent" + objDT.Rows[intCurrentCount]["Student_Name"].ToString();//You can change with Student_ID
                            lnkStudent.Text = objDT.Rows[intCurrentCount]["Student_Name"].ToString();
                            lnkStudent.CommandName = objDT.Rows[intCurrentCount]["Student_ID"].ToString();
                            lnkStudent.Font.Bold = true;
                            lnkStudent.Font.Size = 13;
                            lnkStudent.Width = 10;
                            //Create dynamic click event for all link buttons
                            lnkStudent.Click += new EventHandler(lnkStudentDetails_Click);
tblRowDef.Controls.Add(tblCellDef); intCurrentCount += 1; } } } tblStudents.Controls.Add(tblRowDef); } } pnlStudentDynamic.Controls.Add(tblStudents); } protected void lnkStudentDetails_Click(object sender, EventArgs e) { LinkButton lnkStudent = (LinkButton)sender;
        //Redirect to student details page
        Response.Redirect("StudentDetails.aspx?ID=" + lnkStudent.CommandName);

If this post was help to you. Then Share this to your friends. Thanks!

Solution:The type or namespace name 'SqlConnection' could not be found (are you missing a using directive or an assembly reference?)

How to fix - The type or namespace name 'SqlConnection' could not be found - error in asp.net?:
                                                         "The type or namespace name ' SqlConnection ' could not be found (are you missing a using directive or an assembly reference?)" error means you just missed to add appropriate namespace for connect your sql database. To fix this issue you just add  the following  namespace in your page top.

            using System.Data.SqlClient;

ASP.NET: How to Show/ Hide Div Tags based on radio button selection

Show/hide div based on radio button selection in asp.net:
                                                                       This post will show you how to create a hidden Div and display it with the click of a link. The following code will Show / Hide a div tags  when changing the selection of a radio button.

Sample code for show/hide div tag from code-behind using asp.net:

@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Hide div</title>

    <script runat="server">
        protected void rbtnHideDiv_SelectedIndexChanged(object sender, System.EventArgs e)
            if (rbtnHideDiv.SelectedItem.Text == "Red")
                divRed.Style.Add("display", "none");
                divGreen.Style.Add("display", "inline");
            if (rbtnHideDiv.SelectedItem.Text == "Green")
                divGreen.Style.Add("display", "none");
                divRed.Style.Add("display", "inline");

    <form id="form1" runat="server">
        <asp:RadioButtonList ID="rbtnHideDiv" runat="server" AutoPostBack="true" OnSelectedIndexChanged="rbtnHideDiv_SelectedIndexChanged">
    <div style="background-color: Red" id="divRed" runat="server">
        <asp:Label ID="lblTextRed" SkinID="label_information" Text="My background is RED"
            ForeColor="White" runat="server"></asp:Label>
    <div style="background-color: Green" id="divGreen" runat="server">
        <asp:Label ID="lblGreen" SkinID="label_information" Text="My background is GREEN"
            ForeColor="White" runat="server"></asp:Label>


Sample code for show/hide div tag using java script in asp.net:

<head runat="server">
     <script type="text/javascript" language="javascript">

         function hideDiv() {
             document.getElementById('div1').style.display = 'none';
             document.getElementById('div2').style.display = 'none';

             if (document.getElementById('rbtnMain_0') != null) {
                 if (document.getElementById('rbtnMain_0').checked) {
                     document.getElementById('div1').style.display = 'block';

             if (document.getElementById('rbtnMain_1') != null) {
                 if (document.getElementById('rbtnMain_1').checked) {

                     document.getElementById('div2').style.display = 'block';

    <form id="form1" runat="server">
      <asp:RadioButtonList ID="rbtnMain" runat="server" onchange="hideDiv()">
            <asp:ListItem Text="rb1" Value="1" Selected="True"></asp:ListItem>
            <asp:ListItem Text="rb2" Value="2"></asp:ListItem>
        <div id="divmain">
        <div id="div1">
           div1 <asp:Button ID="Button1" runat="server" Text="Button" />
        <div id="div2" style="display:none">
           div2  <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
If this post was help to you. Then Share this to your friends. Thanks!




Blogger Widgets