am just figuring out best practice with MVC now I have a project where we have chosen to use it in anger.My question is.If creating a list view which is bound to an IEnumerable is this bad practise?Would it be better to seperate the code generated by the WCF Service reference into a datastructure which essentially holds the same data but abstracts further from the service, meaning that the UI is totally unaware of the service implementation beneath.or do people just bind to the proxy object types and have done with it ?My personal feeling is to create an abstraction by creating a model and placing the Collection in that and referring to the collection in the UI code from the model.
I am trying to add a web reference to an ASP.NET 2.0 application in Visual Studio 2008.However, the generated proxy classes do not include BeginXXXX and EndXXXX methods.Hcan I get these to be generated? Do I need to manually use wsdl.exe?(Incidentally in ASP.NET 3.5 apps, there is an option in the Add Service Reference box which lets me specify that Async methods should be generated. However, I am limited to ASP.NET 2.0 implementation).
I am using Reporting Services to render a report directly to PDF. It requires that I use two web references: ReportExecution2005.asmx and ReportService2005.asmx. The performance on web references seems really poor. Since my web server (IIS7) and my SQL Server (2008) are on the same box, is there a way I can reference them directly? If not is there any way I can explicitly cache them or something. First load is really really slow, second load is perfectly acceptable.
We have 7 different development environments and only 1 domain name. Whenever we want to hit the particular environment we change the host file entry and modify the IP address to that domain name.
We are creating a web application which checks the health of all these servers. But the problem is we have to modify the hostfile of the system from the code to point to different environment this requires administrative previlages and so this is not best approach. Is there any way to hit the particular environment without touching the host file by using some kind of proxy?
I have an entity object as model input in my view. Not sure if it's the best approach, but I use the object references to get values from a related object.Let's say I've got a car entity and a manufacturer entity.Here's how it would look in my view
[Code]....
I've get a nullreferenceexception where the car entitity does not have a reference towards manufacturer. I'd like to output a " " if no manufacturer exists.
""Object reference not set to an instance of an object."" Protected Sub CreateUserWizard1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.Load Dim SQLData As New System.Data.SqlClient.SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.MDF;Integrated Security=True;User Instance=True") Dim cmdSelect As New System.Data.SqlClient.SqlCommand("SELECT TOP 1 EmployeeId FROM a1_admins Order by Id DESC", SQLData) Dim label11 As Label = CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Label11") SQLData.Open() Dim dtrReader As System.Data.SqlClient.SqlDataReader = cmdSelect.ExecuteReader() If dtrReader.HasRows Then While dtrReader.Read() label11.Text = dtrReader("EmployeeId") End While End If dtrReader.Close() SQLData.Close() End Sub End Class
I'm getting the object refernce not set to an instance of an object error in the code below.I couldnt figure it out, where I'm going wrong.VB.NET Syntax (Toggle Plain Text)
I'm trying to include script and style references that will not break on deployment, however I can not even get the references to work locally. I have tried using Url.Content() and MVCContrib's <%=Html.ScriptInclude("")%>.
My scripts are in a Scripts folder on the root of the site; my styles are in the usual Content/css/ folder.
Everything works fine on my dev machine which is running Windows 7. However, when I deploy my app to my production server at MaximumASP running 64 bit Windows 2008 R2 Standard, I just can't access those pages that are handled by my URL Routing logic. I'm getting the infamous "Object reference not set to an instance of an object." error.
The code below is my URL handler for Mailbox module in my application. I've defined mail folders in my database. All this does is if user is looking for /mailbox/Inbox, it looks up the folderID and sends the user the mailbox.aspx page which is expecting a folderID
I am updating some CS code that was written in 2004, and that references some assemblies which extract user data from AD by query filtering on the user's title. I can't test my updated code in VS2010 because the assemblies no longer compile - the references are no longer valid (I can't create a DirectoryEntry or DirectorySearcher) so I need to work out how to replace the code with current directoryservices.accountmanagement namespace properties and methods. I have searched around but don't seem to be getting anywhere. give me some code that will work with vs 2010 to replicate the following:
I want to embed video in object tag and I want to put the value of param from code-behind. But I'm not able to put the value from code-behind. Any idea where I'm getting wrong?This is my code so far:
i need to hide an object(any control)on .aspx page for a perticulat user,
For Example::
I have two controls one is a lable control and another one is a button control on my Default.aspx page, and there are two users A and B, Lables control can be visible for A and B. But Button control is only visible for A but not to B. to do this i dont have to use any C# or VB code.
I've got a vs08 web site project that was recently added to tfs2010. now when i look at the code behind on a user control, a form object is not found in the code behind.
[code]....
Error:
The name 'txtbxSearchWorkOrder' does not exist in the current context
why this is not working on this page? I've got other pages with textboxes and no issues.
I have the following code to playback video clips.. we are getting to the point where i need to get this setup and populated from our table.. i already have the data i need to put into the needed parameters, but cant figure it out.. i have tried to add runat="server" and add an ID to the parameters i need to control, but when the page loads, the video window is displayed, but no video is available. and at the moment i have the video hard coded to test, but will need to replace that with video links stored in the table.. what am i missing or doing wrong?
I'm having trouble accessing custom profile properties that I've declared in my web.config using the TableProfileProvider available at [URL] I set everything up according to the instructions but keep receiving an error stating "The type or namespace name 'Profile' could not be found" whenever I refer to the Profile object in my codebehind. My web.config is:
I am creating an authentication service. This service has one of the methods to validate username and password and return a status based on it.
The validation method has bunch of things to check before it can say user is valid. This method has a pseudo code similar to this:
If UserName and Password is correct
If User Account is Locked (due to invalid attempts)
{[code]....
As you can see there are lots of if else statements that I am writing. It looks more like a procedural programming rather than object oriented.How can I fit such kind of code in object oriented pattern?
I am creating a web application that allows a user to download a csv file of a gridview. However, after looking at tutorials online such as http://www.aspsnippets.com/Articles/Export-GridView-To-Word-Excel-PDF-CSV-Formats-in-ASP.Net.aspxand such, I successfully got the table I wanted but there are HTML content appended to the table as well.There was also a similar problem being brought up on the forum,http://forums.asp.net/p/1528174/3692826.aspx. The solutions didn't help me much though. However, I am not really sure how Handlers can benefit this. Furthermore, I don't want the user to be navigated to a blank page just to download the csv file. I tried to debug and insert removal code to remove the html code before the response object is being wrote out but seems even at the end of the writing method, the response object seems to be holding just the table content only.
i have defined profile properties in my web config file but unable to access them in code behind. even profile object is not available. i have to writer fully qualified name like System.Web.Profile. below is my web config
I am trying to incorporate AJAX in my web project for the first time and it isn't working. I don't know how to instantiate a class once and use AJAX to update the dataset numerous times before updating the database changes using a postback.
My project is to learn AJAX with a class object. Clicking the button is supposed to increment a count by one using a class to store the count. Here is my class:
[Code]....
Here is my HTML code:
[Code]....
And here are my button click event code snippets:
[Code]....
My problem is that as I step through the code (after clicking on the second button) it instantiates a new class object each time which returns a value of 2 every time. I have tried to fix the problem by putting my counter class instantiation in the pageload event using "If Not IsPostBack Then ..." but my probem there is that the button click event block of code would not recognize the cCount class - it put the blue lines under the cCount
My goal is to have the class object available to multiple events in the code behind: especially using AJAX to build records in one of my DataSet tables Does anyone know how to handle this?
Error: Microsoft JScript runtime error: Object expected
if (lstRecipient.Items[i].Text == ddlRecipient.SelectedItem.Text) { lstRecipient.Items.RemoveAt(i); isDuplicate = true; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertAdd", "jAlert('Recipient name is already in the list.', 'Duplicate Entry!');", true); }
I'm working to move my simple asp.net website to a three layer architecture. Currently I have Linq queries like the one below in my code-behind files. Basically this code snippet retrieves a collection of customer data from the database and then binds it to a grid control.
I'm wondering if someone can guide me on how to rewrite this in order to move it to my newly-created data access layer. I'm thinking I will turn it into a class (e.g. GetUserBoxesByStatus()) that can be reused throughout the site.
var boxes = from p in sbm.Packages where p.UserID == CurrentUserId && p.StatusID > 1 && p.StatusID < 3 select new { p.PackageTag, p.PackageName, p.DateReceived, p.DateShipped }; [code]....
Some of the options that I've investigated but have not had success implementing are the following:
DataTable --- returning a DataTable seems like the best solution but it also appears to require a lot of potentially unecessarry code to define a table (isn't the data source already mapped in my Linq 2 Entities dbml?)
IEneuerable --- I think I could pass an IEnumerable list between the layers but after reading many tutorials about Linq I'm still a little lost DTO --- Conceptually I think I understand what a DTO is but I am not clear on how to begin implementing this approach POCO --- Again, the concept seems logical enough but I don't know how to put this into practice
how they would tackle this using one of the above or some other solution.