.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

Iterate through all areas

Posted By:      Posted Date: September 02, 2010    Points: 0   Category :ASP.Net
I am wondering if MVC offers a handy function to iterate through all areas.  I know I can search the sub-directories of Areas to achieve this.  I am just curious.

View Complete Post

More Related Resource Links

areas mvc2 iis 6.0


hi all,

i have another problem. I am trying to deploy my MVC2 website on iis 6.0. I have added the following to my global.asax:


routes.MapRoute("Default","{controller}.mvc/{action}/{id}", new {controller = "Home", action = "Index", id = UrlParameter.Optional } );

I added the ".mvc" extention because i read that iis 6 needs this. And it works. BUT!! I also use areas, and this is something iis 6 does not understand.

I have the following:
No Areapath: Home.mvc/Index (works fine, no area used)
Areapath: Projects/Overview/Index (does not work!!)

I don't now how to solve this, i hope somebody can help me.




ASP.NET MVC3 Areas and Razor views produce errors?


The view at '~/Areas/SomeArea/Views/List/Index.cshtml' must derive from ViewPage, ViewPage, ViewUserControl, or ViewUserControl.

The project structure is pretty much default. There is one area called SomeArea. It has a single controller called List. It does nothing except:

public ActionResult Index()
    return View("~/Areas/SomeArea/Views/List/Index.cshtml");

The view looks like:

@inherits System.Web.Mvc.WebViewPage<dynamic>
    View.Title = "Index";
    LayoutPage = "~/Views/Shared/_Layout.cshtml";


I have tried emptying the entire file part by part and nothing seems to help. If I create a controller and view outside the area it works just fine. If I create an aspx view it works fine as well. Is it possible the default razor view engine doesn't support areas at this time?

The areas are registered too.

public static void RegisterRoutes(RouteCollection routes)
        "Default", // Route name
        "{controller}/{action}/{id}", // URL with parameters

how can i iterate through a table using javascript



how can i iterate through a table using javascript

each row in a table shows a  a  decimal value , i want to calculate the total  with out using server codes


Iterate through profile information


I have a site I'm working on where the values being stored in user profiles can change so I need to iterate through all available profile options and display them (say in a label or gridview for instance).

Here is an example of a web.config I threw together

<profile enabled="true">
        <group name="Demographics">
        <add name="FirstName" type="String"/>
        <add name="LastName" type="String"/>

Failure to reliably iterate through all elements of a COM Collection from C# .NET 4.0

In C#, .NET 4.0, I am making a call to a COM DLL to return a collection object. A foreach loop steps through each element of the collection. In the loop, a new .NET object is created for each element of the COM collection. The new object is added to a new .NET collection. This works fine in the development environment. In a deployed system, is works correctly most (about 90%) of the time.  However, sometimes (about 5% of the time) the foreach loop finds no items in the COM collection. Other times (also about 5%), it finds the first 2 or 3 or ... N items.  Somehow, the enumeration interface exposed by the COM object is failing. Here is a code snippet from the COM Object, which is called NameList.  NOTE that the VB6 cls file was opened in a text editor to show the class and method attributes. VERSION 1.0 CLASS BEGIN MultiUse = -1 'True Persistable = 0 'NotPersistable DataBindingBehavior = 0 'vbNone DataSourceBehavior = 0 'vbNone MTSTransactionMode = 0 'NotAnMTSObject END Attribute VB_Name = "NameList" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = True Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes" Attribute VB_Ext_KEY = "Top_Level" ,"Yes" Option Explicit Private mCol As Collection ' <snip> Only code rela

Iterate through rows of dataset in report's custom code

Hello, How can I iterate through the rows of a dataset in the custom code? I have a report containing a dataset. I pass the dataset as a parameter to the custom code function. But what then? Where is a reference about the available members etc.? Here is my dummy sample code so far: Public Function ShowParameterValues(ByVal ds as DataSet) as object() Dim codes() As Object Array.Resize(codes,dc.???.Count) codes(0)=ds??(field???)(row??) return codes End Function As the task I want to accomplish is very simple, I want to keep it in the custom code instead of writing any custom assemblies etc.   Thank you!

iterate through for each

hey im attaching a link to my database image  http://img521.imageshack.us/img521/3299/60742123.png hello, i was wondering what am i doing wrong im using the code below to iterate through each row in my database and print out a certin code for each existing row in my db but for some reason it only prints out the last row.. any ideas? DataTable Info = Cameras.GetCamerasPageInfo(); foreach (DataRow Images in Info.Rows) { string ImgName = Images.ItemArray[4].ToString().Trim(); string Title = Images.ItemArray[5].ToString().Trim(); string Desc = Images.ItemArray[6].ToString().Trim(); Literal2.Text = @"<li><a href=" + "\"Img/" + ImgName + "" + "\">"; Literal2.Text = Literal2.Text + @"<img src=" + "\"Img/" + ImgName + "" + "\" height=" + "\"60px" + "\" "; Literal2.Text = Literal2.Text + @"title=" + "\"" + Title + "\" alt=" + "\"" + Desc + "\"" + "></a></li>"; }  

iterate till to get n-th level of foreign key inforamtion.

Hi.. how can i fetch n-th level of all foreign key's information? for example: one table is 'A', second table name is 'B', third tables is 'C' and so on table 'A' has a primary key, table 'B' has foreign key against table 'A' and table 'C' has foreign key of table 'B' and so on.. i want to make a such dynamic script which can get all/n-th level of foreign key relation inofrmations against. i made below script which can get foreign key information dynamically but it is used for single level not for n-th level. ALTER PROC [dbo].[sp_sng_fetching_foreign_key_info] @p_table_name varchar(100) , @flag bit AS DECLARE @pk_table_nme VARCHAR(150) DECLARE @fk_table_nme VARCHAR(150) DECLARE @pk_col_nme VARCHAR(150) DECLARE @fk_col_nme VARCHAR(150) DECLARE @constraint_nme VARCHAR(150) DECLARE @flg bit BEGIN set @flg = @flag DECLARE GETTING_ALL_FOREIGN_KEY_DATA CURSOR FOR select ISNULL(c.constraint_name,''), ISNULL(cfk.table_name ,''), ISNULL(kcu.column_name ,''), ISNULL(cpk.table_name ,''), ISNULL(pkt.column_name ,'') from information_schema.REFERENTIAL_CONSTRAINTS c INNER JOIN information_schema.TABLE_CONSTRAINTS cpk on c.unique_constraint_name = cpk.constraint_name INNER JOIN information_schema.TABLE_CONSTRAINTS cfk on c.constraint_name = cfk.constraint_name INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu ON c.constrai

How do i iterate through an XML document?

hi friends, i have tried to read through an xml variable and insert values to a table using the following fucntion:   if exists (select 1 from sys.sysobjects where type = 'TF' and name = 'fn_get_int_table_frm_xml') drop function fn_get_int_table_frm_xml go create function fn_get_int_table_frm_xml ( @xml_values xml ) returns @indexes table (idx int identity(1, 1) primary key, usr_id int, Role_id int) as begin declare @ret xml declare @rle_id, @usr_id int set @ret = @xml_values select UserID, RoleID from openxml('@ret', 'Roles/Role'); -- how to insert each child element to the @indexes table? return end go The @xml_values content is like this: <Roles> <Role> <UserID>10</UserID> <RoleID>200</RoleID> </Role> <Role> <UserID>10</UserID> <RoleID>300</RoleID> </Role> <Role> <UserID>10</UserID> <RoleID>400</RoleID> </Role> </Roles>' How do i extract each UserID and ROleID in each Role and insert to the virtual table @Indexes? thanks

ASP.NET MVC 2 prefix routing (similar to CakePHP) with Areas support

If anyone is interested, I have figured out how to do CakePHP style prefix routing with ASP.NET MVC 2.Feel free to post changes or suggestions!  I have spent hours combing google to try to fit these peices together.(Please excuse the  pasted code,  the code inserter was messing up the line breaks.)First of all if you are not familiar with cakephp, it is an MVC framework for PHP that is similar to Rails.It has a concept of prefix routing (sometimes called admin routing).  What this does is turn a route like this:  /admin/controller/action  into  controller::admin_action.It basically extracts the 'admin' part out of the Url and prefixes the action name with it.  This is beneficial because it allows you to have separate actions in the same controller that are targeted for an administrative account, or any other use you can think of.  By using the actionlink generator, if you do not specify a 'prefix' it will assume that you are using the same prefix.  This is great because now you can use partial views for navigation in both views 'admin_index' and 'index'  and it will remember which prefix you are using.  (DRY)  ex: <%=html.actionlink('name','someaction')%>  if used in an admin view will generate a link to admin_someaction.  With .NET MVC 2 there is a n

Iterate data row to find errors.


Hi, I have an asp website, and a dataset with a datatable. When I check I after configuring it it shows all the data. But when I run the code I got an exception

System.Data.ConstraintException was unhandled by user code
  Message="Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."

I want to figure it out with iterating datarow.

Some codes are here but I need help to iterate datarow.

public partial class tabRegionExtremeList : System.Web.UI.Page
    DataSet1TableAdapters.droughtDataTableAdapter k1 = new DataSet1TableAdapters.droughtDataTableAdapter();
    DataSet1.droughtDataTableDataTable k2 = new DataSet1.droughtDataTableDataTable(); 
    String [][]ExtremeList;
    protected void Page_Load(object sender, EventArgs e)
    private void getRegionExtremeList()
            // How to catch error by iterating Datarow here
            // such as using 
          // foreach(...)



iterate throw rows of Template Column in Datagrid



I am using WPF DataGrid (VS 2008). i am using Template column with a button in it i want to change the content of the button(Caption) when it is clicked .i am doing it in its click event ,but it  changes the content of only the button clicked(only one row). i want to change the content of button in all rows.

how can access the button instance of all rows in this template column.



How do i iterate through a table that does not have an index column?


hi friends,

I have the following table variable that i store rows extracted from an xml document;

declare @tbl_ans table ( AnsText nvarchar(max), IsCorr bit)

this cannothave an index column.

assume it has 25 rows, i need insert each row to a table  that has three columns

That Answers table has following structure:

a_idx int,

a_text nvarchar(max),

is_active int,

upt_date datetime

The script should iterate through the @tbl_ans_table table and insert each to the answers table then i should fetch each a_idx in each iteration and insert it to another. But the problem is how itereate through @tbl_ans_table without an index?



Iterate the rows in the datagrid and compare it with the systemclock



How would I iterate the rows in the datagrid? The 4th column contains the time, I would like to compare it with the systemclock and enter "ACTIVE" in the 5th column if the time value in the 4th column is equal to the system clock?

I tried FOR EACH.. but I can't get it right.. Please help.

How do I programmatically iterate through different pages in a GridView?


OK I am a total novice to VB so bear with me.In my web-based project, I pass an ID field as a parameter in my URL and go through each row in my gridview to find the correct row that matches the ID parameter, like so: 

Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.DataBound
 REM if valid ID parameter was given in URL
 If Not Request.QueryString("ID") Is Nothing AndAlso _
  IsNumeric(Request.QueryString("ID")) Then
  Dim bItemNotFound As Boolean = True
  Dim i As Integer
  Dim iSelectedIndex As Integer = -1

  REM Loop through the items in the GridView
  For i = 0 To GridView1.DataKeys.Count - 1 Step i + 1

   REM Found the correct item
   If Request.QueryString("ID") = GridView1.DataKeys(i).Value Then
    bItemNotFound = False
    iSelectedIndex = i
    Exit For
   End If

  If bItemNotFound = False Then
   GridView1.SelectedIndex = iSelectedIndex
   GridView1.SelectedIndex = -1
  End If

 End If
End Sub

The problem is that this code only works if the corresponding ID is in a row displayed on the first page. I want to loop through each page in the gridview's rows until either the correct ID is found or it reaches the end of the data set. How do I

How to iterate to Profile pictures?


User stored his/her profile picture in "Shared%20Pictures/Profile%20Pictures/bhind8ball.bmp" path in SSP. How to get this List item using this url? Or How to iterate SharePicture/ProfilePicture to get this List item using SPQuery?


Please share thoughts.


Multiproject areas in ASP.Net MVC 3


Does any one have any idea about multiproject area support in asp.net mvc 3? As it was degraded to future status in mvc 2. If it is still not included then should we look forward for ASP.Net MVC Portable Areas via MvcContrib. Can you share your expreriences?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend