Click here to Skip to main content
15,895,667 members
Articles / Web Development / HTML

Webpart/Portlet development in ASP.NET MVC Framework

Rate me:
Please Sign up or sign in to vote.
4.84/5 (40 votes)
5 Feb 2015CPOL5 min read 206.5K   7.3K   163  
Solution adorned with drag and drop Portlet/Webpart customization feature in ASP.NET MVC Framework. It summoned JQuery for better user experience evading inclusive page refresh during personalization.
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
    <% 
        System.Data.DataRow[] rows = ((WebApplication.Models.ds)Application["data"]).Category.Select();
        System.Data.DataRow[] piRows = rows;
        int total_Category_Protlets = 0;
        string status_Filter = " Is_Active = " + ViewData["is_Active_Portlets"].ToString();
        int total_Portlets = ((WebApplication.Models.ds)Session["data"]).Portlet_User.Select(status_Filter).Length;
        string funct_Name = "";
        string status = "";
        if (Convert.ToBoolean(ViewData["is_Active_Portlets"]))
            status = " Active ";
        else
            status = " Disable ";
    %>
    
    <%-- application pagetabs are generation  --%>
    <div id="tabs" style="min-height:500px;height:100%"> 
    <b style="color:Black">Total : </b><i id="currentActivePortlets" style="color:Black"><%= total_Portlets.ToString()%></i>&nbsp;&nbsp;<b style="color:Black"><%= status %> RSS Feeds</b>
    <ul>
        <% foreach (System.Data.DataRow row in rows)
           {  %>  
            <% total_Category_Protlets = ((WebApplication.Models.ds)Session["data"]).Portlet_User.Select( status_Filter + " and Category_ID = " + row["Category_ID"].ToString()).Length; %>  
        <li ><a id='<%= "tab" + row["Category_ID"].ToString() %>'     href='<%= "#tabs-" + row["Category_ID"].ToString() %>'>
                    <%= row["Category"].ToString() + " ( " + total_Category_Protlets.ToString() + " ) "%></a></li> 
	    <%} %>
    </ul> 
    
    
 	<%-- application pagetabs contents generation that is portlets/webpart   --%>
	<% foreach (System.Data.DataRow catRow in rows)
    {  %>  
        <% funct_Name = "catRadButton" + catRow["Category_ID"].ToString(); %>
        <script type="text/javascript">
	        function <%= funct_Name %>() {
	            
	            if( $('<%= "#radio1-" + catRow["Category_ID"].ToString() %>').is(':checked') )
	            {
	                $('<%= "#" + "tabs-" + catRow["Category_ID"].ToString() %>' ).find(".portlet").find(".portlet-content").toggle(true);
	                $('<%= "#" + "tabs-" + catRow["Category_ID"].ToString() %>' ).find(".portlet-header .ui-icon-plusthick").toggleClass("ui-icon-minusthick").toggleClass("ui-icon-plusthick");
	           	                
	            }
	            else
	            if( $('<%= "#radio2-" + catRow["Category_ID"].ToString() %>').is(':checked') )
	            {
	                $('<%= "#" + "tabs-" + catRow["Category_ID"].ToString() %>' ).find(".portlet").find(".portlet-content").toggle(false);
	                $('<%= "#" + "tabs-" + catRow["Category_ID"].ToString() %>' ).find(".portlet-header .ui-icon-minusthick").toggleClass("ui-icon-minusthick").toggleClass("ui-icon-plusthick");
			    }
	            else
	            if( $('<%= "#radio3-" + catRow["Category_ID"].ToString() %>').is(':checked') )
	            {
	                
	            }
            }
	    </script>
        <div id='<%= "tabs-" + catRow["Category_ID"].ToString() %>' style="width:100px" > 
        <table width="300px" >  
            <tr>
                <td colspan="3" >
                    <input type="radio" onclick=<%= funct_Name %>()  id="<%= "radio1-" + catRow["Category_ID"].ToString() %>" name='<%= "cat-" + catRow["Category_ID"].ToString() %>'  /><label for='<%= "#radio1-" + catRow["Category_ID"].ToString() %>' style="color:#5c87b2" >Expand</label>
			        <input type="radio" onclick=<%= funct_Name %>() id="<%= "radio2-" + catRow["Category_ID"].ToString() %>" name='<%= "cat-" + catRow["Category_ID"].ToString() %>'  /><label for='<%= "#radio2-" + catRow["Category_ID"].ToString() %>' style="color:#5c87b2" >Collapse</label>
			        <input type="radio" onclick=<%= funct_Name %>() id="<%= "radio3-" + catRow["Category_ID"].ToString() %>" name='<%= "cat-" + catRow["Category_ID"].ToString() %>'  checked=checked  /><label for='<%= "#radio3-" + catRow["Category_ID"].ToString() %>' style="color:#5c87b2" >None</label>
                </td>
            </tr>
            
            <tr>
                <%-- intializing tabpage first column --%>
                <td valign=top style="width:100px; vertical-align:100%">
                    <%-- intializing value for portlet/webpart that would passed to partial view as parameter for further assesment  --%>
	                <% 
                        ViewDataDictionary vdd = new ViewDataDictionary();
                        vdd["category_ID"] = catRow["Category_ID"].ToString(); 
                    %>
                    <%-- first coulumns pagetabs portlets/webpart generation  --%>
		            <div  id='<%= "portletColumn1" + catRow["Category_ID"].ToString() %>'  class="column" style="margin: 0 0px 0px 0px; padding: 5px; font-size: 1.2em; width: 285px;">
		                <% 
                        piRows = ((WebApplication.Models.ds)Session["data"]).Portlet_User.Select(status_Filter + "  and Category_ID = " + catRow["Category_ID"].ToString() + " and Column_No = 1 ", " Row_Sequence asc ");
                        foreach (System.Data.DataRow piRow in piRows)
                        {
                            vdd["Portlet_ID"] = Convert.ToInt32(piRow["Portlet_ID"]);
                            vdd["Title"] = piRow["Title"].ToString();
                            Html.RenderPartial("Portlet", vdd);
                        } 
                        %>
		 	        </div>
        		  </td>
           
                <%-- intializing tabpage second column --%>
                <td valign="top" style="width:150px" >
                    <%-- second coulumns pagetabs portlets/webpart generation  --%>
                    <div id='<%= "portletColumn2" + catRow["Category_ID"].ToString() %>'  class="column" style="margin: 0 0px 0px 0px; padding: 5px; font-size: 1.2em; width: 285px;">
		                <% 
                            piRows = ((WebApplication.Models.ds)Session["data"]).Portlet_User.Select(status_Filter + "  and Category_ID = " + catRow["Category_ID"].ToString() + " and Column_No = 2 ", " Row_Sequence asc ");
                        foreach (System.Data.DataRow piRow in piRows)
                        {
                            vdd["Portlet_ID"] = Convert.ToInt32(piRow["Portlet_ID"]);
                            vdd["Title"] = piRow["Title"].ToString();
                            Html.RenderPartial("Portlet", vdd);
                        } 
                        %>
        		    </div>
		   	    </td>
		   	    
		   	    <%-- intializing tabpage third column --%>
                <td valign="top" style="width:150px" >
                    <%-- second coulumns pagetabs portlets/webpart generation  --%>
                    <div id='<%= "portletColumn3" + catRow["Category_ID"].ToString() %>'   class="column" style="margin: 0 0px 0px 0px; padding: 5px; font-size: 1.2em; width: 285px;">
		                <% 
                            piRows = ((WebApplication.Models.ds)Session["data"]).Portlet_User.Select(status_Filter + "  and Category_ID = " + catRow["Category_ID"].ToString() + " and Column_No = 3 ", " Row_Sequence asc ");
                        foreach (System.Data.DataRow piRow in piRows)
                        {
                            vdd["Portlet_ID"] = Convert.ToInt32(piRow["Portlet_ID"]);
                            vdd["Title"] = piRow["Title"].ToString();
                            Html.RenderPartial("Portlet", vdd);
                        } 
                        %>
        		    </div>
		   	    </td>
		    </tr>
	     </table>
	    </div> 
  	<%} %>
</div>
 

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Pakistan Pakistan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
This is a Organisation

33 members

Comments and Discussions