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

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Displaying linq in web page

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
 I have gotten as far as joining tables successfully (three of them, no probs) and have placed the data in a "var course_units", which is then passed to the view with the statement:             // Create the view model            var viewModel = new CourseViewMapViewModel()            {                Categories = categories.ToArray(),                NumberOfCategories = (course_units.Distinct()).Count(),                Course_Units = course_units.ToArray(),                Weekly_Hours = weekly_hours.ToArray(),                Total_Hours = total_hours.ToArray(),                         };            //Return the view        &n

View Complete Post

More Related Resource Links

Passing Linq Statement between master and content page


I usually work with windows forms, and am just starting to work with ASP.Net, so appologies if this is a dumb question!

I have a master page which has a search button on it. The results of this are built up using a Linq statement and if there are any results, I want to display the results in a contents page.

On the masterpage, I have the following code:

Private _res

    Public Overridable ReadOnly Property SearchRes()
            Return _res
        End Get
    End Property

 Private Sub DoSearch()
   'some code to get a linq result

    If res.Any Then
            _res = res
            Server.Transfer("SearchResults.aspx", True)
            'no results
            LabelNoRes.Visible = True
        End If
 End Sub

On the SearchResults.aspx page I have this code.

Dim m As pxSite = CType(Page.Master, MasterPage)
        If m.SearchRes IsNot Nothing Then
            Label1.Text = "Results found = " & m.SearchRes.Count
        End If

m.searchRes is always nothing. 

What am I doing wrong here?


Page layout list not displaying in page settings



I have 4 different custom page layouts in my publishing site at the site collection level. I have one site named "Services" in site collection. When i create page, i select one page layout from above 4. But when i go to the page settings of that page to change the page layout of it, i can see only one page layout which this page based on.

Problem is why all the page layouts not listing there? I checked "Page layout and site templates" settings from look and feel of Site Settings, this r set to "Pages in this site can use any layout".

Please help..!

Thanks in advance.


Sandip Patil

Sharepoint Developer


Problem displaying a page using window.showModalDialog when resizing it.

 Hi, I have a page that is displayed using window.showModalDialog, when the page is resized the tables, text boxes and everything else that is in the page with the width 100% doesn't resize (fit the page) unless a post back is used.How can I make the page keep everything in proportion when it is resized without the need to post back? 

Custom Webpart not working on "My Profile" page but works on all other pages. Linq Problem?

Hi, I created a publication site and in that site i created pages with specifique metadata (using a pagelayout with a custom content type)0. My webpart is getting data from those pages and displaying it. My webpart works on every page except on the "my profile" page(overview tab). I get the following error: Invalid Url: /TestSites/course I used the SPMETAL to create a class and i'm using this class to retrieve the data from the pages (with linq). The url i give to the entity is http://pcp/TestSites/course  this works fine on every site except on the my profile page. Can anybody help me? Here is the code i use to retrieve my data: EntitiesDataContext ctx = new EntitiesDataContext(courseSite); //Code below gets only the pages with a courses contentType. //EXCEPTION TRIGGERT ON THE FOLLOWING LINE IF IN PROFILE PAGE EntityList<Courses> course = ctx.GetList<Courses>("Pages"); //Writing the query to get the correct pages(with the course page layout only! var Query = from myCourse in course.ToList() where myCourse.CourseParticipants.Contains(myWeb.CurrentUser.LoginName) Select new{myTitle = myCourse.CourseTitle, myCompany = myCourse.Company, myPath = myCourse.Path, myName = myCourse.Name }; Thx.    

HoverMenuExtender is displaying popup panel on page load


I am using VS 2010 with .Net 4.0.

I am using a HoverMenuExtender to display a text but just after the page is loaded, the popup panel is already displayed.

Any help is appreciated.

How to pass parameter to web page without displaying it?


Hello everybody.

The subject of the thread is my question. I don't know whether or not it is possible. Actually in my project currently I'm feeling a need to capture a bitmap image of a web page to insert that image into pdf document. And according to the need I don't want to display that page but want to pass values as parameters to that page. Is it possible? If so, how can I do it? Any information would be very helpful to me.

Thank you.

Displaying custom error page


For certain parts of the site the allow inserting and updating of data we have some try / catch logic in place..

Now we would like to display a custom error page explaining what didnt happen. Instead of just a generic message that says error occurred.

Here is 1 error that is generated due to Primary Key constraints, we woudl like to redirect them to our error.aspx page which is already setup and configured in the web.config but within that page display a more user friendly detail message of why they got the error. In the example below, we may want to say, "There was an error with the "Access Insert" please make sure that the values you entered on the previous page are unique" thats just an example, but gives an idea of what we are trying to do.



Server Error in '/' Application.

Access Point Insert Error:Violation of PRIMARY KEY constraint 'PK_AccessInfo'. Cannot insert duplicate key in object 'dbo.AccessInfo'.
The statement has been terminated. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Exce

Displaying waiting image when page is loaded in asp.net



I want to display gif image when a page is loaded...

I have a dropdown list when this is selected Gridview is populated with data from database..

I want to show a gif image when this gridview is populated...

how to implement this without AJAX...





select query for linq on Default.aspx.cs page


how do i create linq query and asign that query to as data source to datalist on default.aspx.cs page

displaying 2 alternating db records with each new page load event


I have a webpage which displays content drawn from a single record in a database table. I've been asked to change this so that the content displayed alternates between 2 records each time the page is requested by a browser (I guess this would equate to each PageLoad event).

The records to be displayed are chosen on the basis of two dates, a beginning date and and ending date, that define a time period in which the record is to be active. The table containing these records has 2 columns containing these dates (begin date is contained in "dtDisplay" and end date is "lastDisplay."

I'm not sure how to amend the existing code behind to make this happen. Here is the c# that I inherited from a developer who is no longer available. Thanks for any help:

private void getfeatured_properties()
           string today = DateTime.Now.Date.ToString();

           SqlCommand cmd = common.openDatabase();
           if (cmd.Connection.State == ConnectionState.Open)
                 string sql = "select propID from featured_properties where " +
                    "dtDisplay <= '" + today + "' and " +
                    "lastDisplay >= '" + today + "'";

SP Foundation 2010 not displaying my default site page...



I'm new to Sharepoint and have successfully installed Sharepoint Foundation 2010 on a Windows 7 x64 machine using the instructions on MSDN (instructions are fantastic; by the way).  However, when i completed executing psconfigui.exe (Sharepoint Products and Technologies Configuration Wizard) my default site was not displayed as mentioned in the setup instructions.

Instead I got a webpage cannot be found (HTTP 404) error.  The URL displayed was "http://kweeks-dell"; which doesn't seem right to me.

I was able to run the Central Administration console and display various admin tasks; however, when i tried to create a new site (i.e. "http://kweeks-dell:10178/MyFirstSite"), I get an error message "URL Name contains illegal character ':'".  Where 10178 is part of the URL of the admin site.

I'm really confused cuz i don't see any problems with my installation but yet i cannot get a site setup that i can start work with.

Anyone, I'd appreciate any help I can get.




get the pages 3 to 13 from the pages document library and exclude the displaying page in the sharepo



I have requirement which is ,i am having page document library in the sharepoint site from there we are going to display the all article pages.

My question is:I want get pages from the page document library from top 3 to 13 and exclude the current displaying page.

Explain:i am having a.aspx ,b.aspx,c.aspx,d.aspx pages in the page document library,i need to show those pages in webpart, suppose i am in a.aspx page now i can display b.aspx,c.aspx,d.aspx in that particulate page,And suppose i need to show the pages from 2 to 4 then i can display c.aspx and d.aspx pages in the a.aspx page


please help me ,really appriciate


Displaying two seperate DB objects on the Same Page


What I would like to do using LINQ is display two seperate db objects on the same page using ASP.NET MVC.   So I could have URLs like:



Displays the information for Location1 and items 1 or 2.



Displays the information for Location2 and items 1 or 2.

There is no difference between item1 and item2.   So each location could be associated with each item.

Displaying BLOB data on web page


I have got a db field of type blob. It may contain excel,pdf,doc or any kind of image(jpg,png etc). I want to display according to file format. So please let me know how I can do this

mobile web page is displaying with small font in safari on ipod touch and in iphone.


Hi guys,

I had developed mobile web page in asp.net 2.0.

This page is displaying with small font in safari on ipod touch and in iphone.

for this i had copied iphone.browser definition file in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\Browsers

folder and run the command aspnet_regbrowsers.exe -i in command prompt.

Then 2 files with ASP.BrowserCapsFactory.dll and BrowserCapsFactory.cs were created.

But there is  no result

can any one can solve my problem.

it's urgent


chadra sekhar

Not Displaying Button (Submit) on Home Page


I have about 2,700 pages of old asp pages.  I believe they are over ten years old.


I want to start to go to ASP.NET so this is a very new experience for me.


I want to add a submit button to go to an instruction page on different studies various educational enties have conducted.


I have added the following code, but there is no button visible on my home page.

<asp:button runat="server" id="One" Text="Submit" Value="Studies and Surveys" postBackURL="/StudysS.asp"/>

I know the old way was to just put <Input Type="Submit">


But I want to start converting and doing changes in ASP.NET


Why doesn't My Button Appear?


Thanks in Advance





SPMetal: Using Linq to SharePoint Datacontext to Insert Page


I am trying to insert a Page (on a Publishing Site) in SharePoint 2010 using the generated SPMetal classes.

Here is the code that I am using to insert a page:

using (var dataContext = new MySharePointSite1L2spDataContext("http://localhost"))
  var pages = dataContext.GetList<Page>("Pages");
  Page page = new Page();
  page.Title = "New Page";
  page.Name = "Page.aspx";    
  page.Path = "/Pages";

The code results in an NullReferenceException with the details "Object reference not set to an instance of an object."

Stack Trace:
   at Microsoft.SharePoint.Linq.EntityTracker.AddFile(EntityRef eref)
   at Microsoft.SharePoint.Linq.EntityTracker.SubmitNewEntity(NewEntityRef newEref, Stack`1 visited)
   at Microsoft.SharePoint.Linq.EntityTra
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