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

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

PageData weirdness, works, then doesn not work. Change the 'index' name and it works again

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net

I'm facing a weird issue. I have a page "add.cshtml" in wich I create a PageData object like this:


PageData["myObject"] = new { Message = "some msg", ID = 1, Name = "some name" }

In that same page, I pass the object to a RenderPage:



@RenderPage("form.cshtml", PageData["myObject"])


In "form.cshml", I simply call values like this:


<br />

When I call "add.cshtml", it works, then for some reason, at some point, I get an error stating: "object" does not contain a definition for Message, if I comment the @PageData["myObject"].Message, error occurs on next property.

When this happens, I change "myObject" to another value in both files, and no more compilation error.

Why does this happen?



View Complete Post

More Related Resource Links

returning data as hyperlink works but doesn't work


Please help. I have a form that searches my database and returns results well but each record contains a cell with a link to another html page. The problem is that whether I place the html pages in the same directory as the .asp codes or in a separate directory with the link being an absolute URL, the action of clicking on the link fails to redirect. Is it possible?

The returns are addresses and the link in each record is to it's own address page with google map.

unmanaged C dll works in VS2005 but It doesn't work on other PC without it


I have a VB winforms, I use function from unmanaged C++ dll "Reserva.DLL" (Manifest: <assemblyIdentity type="win32" name="Microsoft.VC80.DebugCRT" version="8.0.50608.0" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>).

I use this code to call the functions:

  Private Declare Sub CreateReserva Lib "RESERVA.dll" ()
    Private Declare Sub DestroyReserva Lib "RESERVA.dll" ()
    Private Declare Sub DatosPozo 

Crawl doesn't work and Query server is not responding; Search works only for old (crawled) contents


We have following three servers with MOSS 2007 STD deployed in SharePoint server farm,


App01- Query Server

App02 - Index Server (We are using this server as dedicated web front end computer for crawling)

SPDBServer - SQL 2005


Search was working fine till 01/05/2008 and it stopped working after this date only for new contents meaning search is still working fine for the old contents which were added before 01/05/2008 but not for new contents added after 01/05/2008.


We have been working to find out reasons why did that happen? We have found following event ids on Query server,


Event ID:10042 - A new query machine, 'App01', has been added to the query rotation based on changes to farm topology.

Why would enabling trace.axd change the way an app works?

Hi Guys,We have a page with a flash control on, on this page the flash control allows the user to upload a file and gives a progress report. When done the tool calls another page called SaveUpload.aspx which saves the file. The tool was not able to call this page for some reason and as soon as I turned on tracing it allowed the page to be called.Anyone seen behaviour like this before?Cheers,Pete

Edit in Datasheet view does not work on one SharePoint 2007 farm, works on another.

The ability to edit in datasheet view on one of our environments no longer works.  I've tried different client machines on different builds and regardless of the install every library, list, etc. when attempting to edit in datasheet view shows as read only.  Our other environments those systems work as intended with those same clients. I've searched all over and haven't found anything that helped.  Any ideas?

Windows Authentication doesn't work after change of admin pass



J have read many answers about

Login failed for user ''. The user is not associated with a trusted SQL server connection

error, but I don't want to mess up in my sql server so I want to be sure that what I do is OK.

Environment description:

In my company, we have our own application wchich we use to connect to database. All users use SQL Server Auth except me. I can log using Windows Auth from server and from my second computer.

Now everything works fine.

- My comp is in our domain 'OurDomian'.

- On server in AD is admin account 'SqlAdmin'.

- In MSSMS in Security->Logins there is account: OurDomian\SqlAdmin

- on my comp account OurDomian\SqlAdmin is added

I can log to sql server from  my comp using 'Integrated Security' in application with no problem.

Problem description:

Problem starts when I change SqlAdmin password on server.

When I connect from my comp I get the above error. But when I connect from server there is no problem.

I searcher application code and I don't think that I have to change somthing in it. Probably I have to change something with account and permissions.

1. Will it bee enough to delete and add again 'OurDomian\SqlAdmi

SqlClient Connection Works Fine with XP, will not work on Windows 7


Hello, I am programming in VS2010 wirting a simple windows forms program. I am using the System.data.SqlClient for a connection. My data Connection code:

'Used for reading data only



Public Function O

javascript script works with alert() and does not fully work without it



Im facing the following problem i have a gridview that i insert an OnClick event to each row in order to be able to click on a row and selecting that row (change the color of the selected row e.tc) my javascript works fine when i have an alert when i remove the alert

then i see the color of the row changing as i click it but then when i move the mouse the color changes back to normal i still get the id of the row since i have a textbox where i put the id content of the e.row.cell[0] value .

I searched the web and i found out that its something to do with ajax and asychronous calls here is the code if the alert is enabled everything works fine this function is called from .c#

protected void GrdEntal_RowDataBound(object sender, GridViewRowEventArgs e)
            if (e.Row.RowType == DataControlRowType.DataRow)

                e.Row.Attributes.Add("onclick", "javascript:getID('" + e.Row.Cells[0].Text + "', '" + e.Row.ClientID + "', '

Server.HTMLDecode works but modal popup doesn't close



As the title of this post already mentioned, I'm using a modal popup window to edit rows in the gridview. One column in the gridview contains an URL code. When I fire the edit button a popup opens and show the URL in a textbox in this format: &lt;http://blablaba/re?add=14&amp;t=2&quot; /&gt;

When I am using the Server.HTMLDecode function, the modal popup doesn't close anymore.

I am using the following code:

<div style="text-align: right; width: 262px">
    <asp:Button ID="BtnCancel" runat="server" Text="Cancel" OnClick="BtnCancel_Click" />

<asp:LinkButton ID="lnkFake" runat="server"></asp:LinkButton>
<asp:LinkButton ID="lnkFakeOk" runat="server"></asp:LinkButton>

<ajaxToolkit:ModalPopupExtender ID="MPE_edit" runat="server" DropShadow="true" PopupControlID="pnlAddEdit"
                TargetControlID="lnkFake" CancelControlID="lnkFakeOk" BackgroundCssClass="modalBackground">

txtURL.Text = Server.HtmlDecode(row.Cells[3].Text);

The funny thing is, when I change it to: txtURL.Tex

Access gridview row using javascript (row/cell index works in IE not in Firefox )


Hello All,

I have a gridview with checkboxes and textboxes. When i click on a checkbox i want the associated textbox to be enabled/disabled. I wrote the for following javascript that.

 for (var i = 1; i <= grid.rows.length - 1; i++) {
                   if (grid.rows[i].cells[0].childNodes[2].checked) {
                       grid.rows[i].cells[1].childNodes[0].disabled = false;
                   else {
                       grid.rows[i].cells[1].childNodes[0].disabled = true;

Code that works in WebDAV does not work when deployed to IIS7



I have been working on a solution that:

1. Connects to a Lotus Domino server to retrieve data from the .nsf file

2. Uses NotesSQL Driver 8.0 (I've tried both System DSN and ConnectionString method)

3. When I view the page using VS 2008 own's WebDAV to test run, it works flawlessly.  Database can be connected and so Data was retrieved successfully. 

However, when I deployed the website to IIS 7, it gives me problem:

Following is the stacktrace from the Event Viewer entry:

Log Name:   Application
Source:    ASP.NET 2.0.50727.0
Date:     02/11/2010 5:04:07 PM
Event ID:   1309
Task Category: Web Event
Level:     Warning
Keywords:   Classic
User:     N/A
Computer:   KITWILLIAM.naim.com
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 02/11/2010 5:04:07 PM
Event time (UTC): 02/11/2010 9:04:07 AM
Event ID: 0ec2d703a5884f92be87faf06f746c00
Event sequence: 4
Event occurrence: 1
Event detail code: 0
Application information:
  Application domain: /LM/W3SVC/1/ROOT/Resrc-4-129331622441589373
  Trust level: Full
  Application Virtual Path: /Resrc
  Application Path: C:\inetpub\wwwroot\Resrc\
  Machine name: KITWILLIAM
Process information:
  Process ID: 2644
  Process name: w3wp.exe
  Account name: NT AUT

Tale of 2 ALMOST Identical Module Signing Scripts...(One Works One Doesn't)


Hello again SQL Guru's

I have been trying to learn and master module signing and have had pretty good success with help from articles such as http://blogs.msdn.com/b/raulga/archive/2006/10/30/using-a-digital-signature-as-a-secondary-identity-to-replace-cross-database-ownership-chaining.aspx?CommentPosted=true  and http://blogs.msdn.com/b/lcris/archive/2005/06/15/sql-server-2005-procedure-signing-demo.aspx and some others as well.

However I am running into a snag in my Sandbox environment. I can sign modules for cross dbase access using certs and these (SELECT, INSERT, DELETE, FX) work but when I try to do (EXEC) they fail. However if I add the user to the DB it works. The user has ZERO, SQUAT, NADA for perms but he has to be there??? Consider this:

2 databases. 1 for WebAccess (WebAXDB) and 1 for CustomerData (DataDB). I create a proc on the DataDB. Signed it and obtained the sig. Created the exact same proc on WebAxDB and signed it with the sig from DataDB. Inside the proc it does a select. My webuser has access to the WebAxDB and can exec the

Change location of a control in C# , it works fine in XP but in window 7 it donot take proper effect


I have created many custom control in my application. In these controls I make some text boxes  visible and invisible and change their locations according to my requirement. These controls work fine when I run application in window XP but when I run this application in windows 7, text boxes don't appear on proper locations and often overlap each other.

Please help me

Code works on aspx but not ascx


Not sure which category to put this question in, so I will put it in here.

Just to give you an idea of the layout of my solution, I have the main project, along with 2 class libraries, BLL and DAL.  (Business Logic Layer and Data Access Layer)

The BLL refers to the DAL and the main project refers to the BLL.

I had a test website and the code worked fine, but the same code will not work on the real project. The only difference is that in the test project, the code was on an aspx code behind, whereas in the real project, it is an ascx code behind (Web User Control )

The code is:

Dim connectionString As String = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString").ConnectionString
        Dim recordEntry As New UserRecord(connectionString)
        recordEntry.UserName = "TestName"
        recordEntry.BMI = bMI
        recordEntry.BMR = bMR
        recordEntry.FTM = fTM
        recordEntry.TDEE = tDEE
        recordEntry.TodayDate = dateForToday

Dim connectionString As String = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString").ConnectionString

HttpHandler works with Visual Studio Development Server debugging, but not otherwise


Hi all,

I'm new to HttpHandlers.  I am writing an HttpHandler that reads uploaded files directly from the request stream to provide progress that can be queried using an AJAX request.  For large files, this seems to be faster than having ASP.NET load the file contents into Request.Files and then streaming the file from there to wherever it goes (Linq to SQL into a VARBINARY column in an SQL Server database.)

My HttpHandler works perfectly when I'm debugging using the Visual Studio Development Server, but doesn't work otherwise.  The application pool for this application in IIS 7 is set to run in Classic Mode, and the Handler Mappings screen in IIS says that I must manage managed handlers in system.web/httpHandlers. 

I set up in my applications Web.config file.

<add verb="GET,POST" path="*.upload" type="Namespace.For.UploadHandler, AssemblyForUploadHandler"/>

It works great, so long as I don't debug with the "Use Local IIS Web server" option.

What else do I need to do to get this to work?


When I use 'publish', site doesn't work when i post data


Arrgghh, I am so tired of dealing with stuff like this

I've got a project, when I put up on another server I point two sites in IIS6 to it

i have

http://www.main.com  pointing to the folder the files are in


http://www.anotherofoursites.com/main pointing to that same folder in it's own "Virtual Application" or whatever IIS calls it when you put a folder into it's own 

If I just "Build" and push all the files up.. both work without issue and as expected...  but when I use "Publish" to precompile, the site works until I post, and then i get nailed with:

Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Link goes to next page but url doesn't change?


I have a text input to get a 'roomID' and an ASP button that calls an 'enterRoom' function:

roomID:<asp:TextBox runat="server" ID="roomID"></asp:TextBox>
                <asp:Button ID="Button1" runat="server" Text="Enter Room!" OnClick="enterRoom" />

In my head tags I have my enterRoom Sub:
    <script runat="server">
        Sub enterRoom(ByVal sender As Object, ByVal e As System.EventArgs)
            Server.Transfer("users/room.aspx?roomID=" & Request.Form("roomID"))
        End Sub

Now when I click that button it essentially goes to the right page in all ways but the URL stays as my default.aspx instead of changing to users/room.aspx?roomID=23423. I've tried it in IE and Firefox with the same results. Is this something I'm not understanding about Server.Transfer or why is this happening and how do I fix it?

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