Pages

Wednesday, November 30, 2011

How to redirect to a URL in ASP.NET MVC action

return Redirect("http://www.google.com");

What is CDATA

Stand for Character Data in XML
Start from
<![CDATA[ 
 End with
]]>

Tuesday, November 29, 2011

My another Orchard module, TagMenuWidget

https://gallery.orchardproject.net/List/Modules/Orchard.Module.TagMenuWidget

You could put this widget into navigation layer as dynamic menu bar.
Steps: 1. Add this widget into navigation part, and setup tags
2. Put these tag into pages
3. Menu bar would be avaible by the title of pages.

How to display System.Data.DataTable data in ASP.NET MVC

public ActionResult TasksByProjectReport() 
{ 
     System.Data.DataTable data = _reportService.GetReportData(
); 
     
return View(data); 
}


@model System.Data.DataTable 
@using
 System.Data; <h2>Report</h2> 
<table> 
    <thead> 
    <tr> 
    @foreach (DataColumn col in
 Model.Columns)     
    {          
        
<th>@col.ColumnName</th> 
    }     
    
</tr> 
    </thead>
         
    
<tbody> 
    @foreach (DataRow row in
 Model.Rows)     
    {         
        
<tr> 
        @foreach (DataColumn col in
 Model.Columns)         
        {              
            
<td>@row[col.ColumnName]</td> 
        }         
        
</tr> 
    }     
    
</tbody> 
</table
>


http://weblogs.asp.net/gunnarpeipman/archive/2011/11/19/asp-net-mvc-simple-view-to-display-contents-of-datatable.aspx

How to make SSO, Single Sign-On in ASP.NET for two sub domains?

1. Put same machine keys setting in two web.config file:
http://rayaspnet.blogspot.com/2011/11/how-to-generate-machine-key-for-aspnet.html

2. Modify following parts in two web.config files:
Name, domain, path and enableCrossAppRedirects

 
<authentication mode="Forms">
  <forms name=".ASPNET" path="/" domain="abc.com" enableCrossAppRedirects="true" />
</authentication>

Wednesday, November 16, 2011

How to integrate ASP.NET membership into YetAnotherForum.net?

http://ewitch.net/docs/YAFMembershipIntegration.pdf

P.S.:
1. When create Membership database, please install all:
aspnet_regsql.exe -E -S sqlserverinstancename -A all
2. YAF and membership database have to be in same database

Tuesday, November 15, 2011

Friday, November 11, 2011

How to use jQuery in Orchard CMS modules?


On the top of cshtml file put following code:
@{
    Script.Require("jQuery");
}
@using(Script.Foot()) {
    <script type ="text/javascript">
    //<![CDATA[
        $(document).ready(function () {
            alert('page loaded');
        });
    //]]>
    </script>
}

How to get selected value of dropdown by Javascript


var selectedvalue = document.getElementById('yourSelectBoxId').value

How to write a Widget for Orchard CMS? Coding, Packaging and installing


1. Coding:
http://orchardproject.net/docs/Writing-a-content-part.ashx
http://orchardproject.net/docs/Writing-a-widget.ashx
2. Packaging:
http://www.orchardproject.net/docs/Packaging-and-sharing-a-module.ashx
3. Installing:
http://www.orchardproject.net/docs/Installing-and-upgrading-modules.ashx

How to change a project type to MVC 3?


Open csproj file from text editor, such as notepad
change ProjectTypeGuids to following setting
    <ProjectTypeGuids>{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>