The Proper Use Of EnsureChildControls()?

Sep 21, 2010

Most often I use it when I am accessing a property of a composite control that depends on a child control.But I have also added it to OnInit of a control so I could make sure a hidden field was added correctly. Just a minute ago I called it in RenderControl because I was having an issue rendering a calendar extender and it fixed it. I am starting to get a little confused on when I need to and when I don't need to call EnsureChildControls and when I should call it.

View 2 Replies


Similar Messages:

All Controls Are Still Null After Calling EnsureChildControls()?

Jul 23, 2010

The way this page is laid out, all of the data is loaded at Page_Init. Well, I have a custom control that is having problems with this though.

I have it on the page like so:

<cc:SomeControl... />

And then I set the value at Page_Init using

MyControl.Value="blah";

Simple stuff..

The Value is an accessor and has something similar to this:

public string Value{
get...
set{
EnsureChildControls();
MyHiddenField.Value=value;
}
}

and it is here that I have a problem. It says that MyHiddenField is null. Is Page_Init just too early for this? Or is there some other function I need to call?

View 1 Replies

Converting VB To C# - What Is Proper Syntax

Jul 6, 2010

I am trying to conver this to C# but Item is not a method in C#

Repno is a string variable of 3 characters

First if rep is not null

then

confirm that Repno the field salespnno from the query.

[code]....

View 2 Replies

Architecture :: A Proper DI Implementation?

Feb 27, 2011

I'm fairly new to dependency injection but it seems like a proper DI implementation will be fairly complex.

For example, DI requires a centralized class that manages the configuration and resolves the dependencies at runtime.

DI is also based on the concept of using interfaces. For example, a SpecialLogger should use an ILogger interface.

The centralized DI manager class will need to register types - for example, associate ILogger to SpecialLogger.

SpecialLogger will also need to implement the ILogger interface so SpecialLogger can be used through the DI ILogger interface.

Therefore, it seems like a sln using DI will need multiple projects to support DI. Here is an example for logging:

* MyCompany.MyDivision.Framework.DI.Management - this would have the DI manager where dependency types are registered and resolved at runtime
* MyCompany.MyDivision.Framework.Logging - this would have the implementation of a logging class. The main logging class would need to implement ILogger.
* MyCompany.MyDivision.Framework.DI.Interfaces - this would have the ILogger interface.

Interfaces would need to be stored in a separate class library from the DI manager because both the DI manager and SpecialLogger use the ILogger interface. Since the DI manager associates SpecialLogger to ILogger a circular reference would be encountered without a separate class library to store the ILogger interface.

View 1 Replies

Proper Way To Populate Dropdownlist Based Off Another Value?

Dec 21, 2010

I'm running into a minor issue with some ASP.Net code I'm working on. For simplicity sake lets say I have two dropdownlists, one that is full of various items and another that is full of other items, but based off the selected item of the first dropdownlist. I currently set variables into hidden inputs to check to see if the item in the first dropdownlist has changed and if it has to change the second dropdownlist, but I'm also having to check to make sure that if something else causes a postback to NOT repopulate the second dropdownlist as to not lose what is currently selected by the user. This check also allows me to make sure that when I navigate away from the page, the correct values are selected and not something replaced by a postback repopulation.

I'm new to ASP.Net/HTML/CSS/Javascript and the like. I know while what I have works, it isn't even close to being the correct way to do things. correct my ways and figure out the BEST way to solve this current problem. Some good ASP.Net tutorial websites would be nice too as I need to keep improving my skills with it.

View 2 Replies

Input String Not In Proper Format

Jul 26, 2010

i am taking string value from textbox name txtLastAppointment no. and want to convert it to int and then store it in databse using Linq to sql but i am getting error "input string was not in proper format" my Input string is 2.

My Code is.
objnew.lastAppointmentNo=Convert.ToInt32(txtLastAppointmenNo.Text);

View 2 Replies

C# - Best Way To Get The Proper Modules Section From The Web.config?

Jan 19, 2011

The code I've used to get the HTTP Modules is basically

HttpModulesSection modules = ((SystemWebSectionGroup)config.GetSectionGroup("system.web")).HttpModules;
// Depending on what we need to do...
//modules.Modules.Add(CreateSomeModule());
//modules.Modules.Remove("SomeOtherModule");

This worked fine up until IIS7. The migration command %SystemRoot%system32inetsrvappcmd migrate config "website/" moves the modules into system.webServer, so my code is now updating the wrong section. Is there a built in way to get the proper module section that should be modified? Or do I have to add a check for the Request.ServerVariables["SERVER_SOFTWARE"] and return system.web/system.webServer depending on the string I get back?

View 1 Replies

C# - Proper Way To Handle Several Automatic Redirects?

Dec 14, 2010

I have a website that basically allows customers to build a cart with an item that can be configured. A user will pick an item, and they'll be prompted to pick the first option they want, they get sent to the second step where they pick their second option, etc. The number of steps and the number of options are variable, as they are defined by the client. Usually the item only has 2-3 steps with 5-10 options. However, in order to make it faster for the customer, if there is only one option available for the given step, it will automatically be chosen and the user will be sent to the next step.

A client decided to set up an item with 10+ steps with only one option for each step. This results in the entire process automatically choosing everything. FireFox doesn't like this, as it gives the error Firefox has detected that the server is redirecting the request for this address in a way that will never complete. I haven't checked IE or Chrome, although it probably gives similar errors).

What's the best way to fix this? Right now the process is basically User picks item user picks option if there is more than one option available. Otherwise the website does step 3 itself. POST to add the option to the cart Redirect to Page.aspx?step=# repeat step 2-4 as many times as necessary

Is there any change I can make to the code or page so that FireFox doesn't think I'm in an endless loop?

View 2 Replies

Errors Not Viewable Despite Proper Configuration

Feb 27, 2011

I'm having the classic (dare I say typical?) error on the ASP.NET production server, which tells me that I can't view errors. Below the error displayed below, are things I've already tried. In IIS Manager (6.0), the application is located under one of the web sites in "Web Sites". It is indeed a web application, as opposed to a virtual directory (it has that gear icon). When trying to view the error from the localhost (i.e. the server itself), it doesn't find the application on its path, even though the root web site works just fine from localhost. It is clearly not a firewall issue because first of all, the firewall is turned off, and second because the root web site works fine from localhost. Heck, I even tried connecting through telnet and that worked fine and dandy too, so it is most certainly and very clearly not a firewall issue. Basically, I just need to view the error at all. I won't have to fix this problem if I can just see the error and fix it, because obviously there is something wrong in the code itself... I just don't know what, because IIS/.NET won't tell me.

Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off".

So what I've already tried is what the error message itself suggests by setting the customErrors thing to "Off". In fact, it always was on "Off" so I didn't have to change anything. I've made sure that the web.config XML is valid. Another common reason for this error is that the .NET run-time is set to version 1.1, not 2.0. I've also made sure that this is correctly configured to 2.0. I'm running it in an independent application pool, meaning that there are no other applications at all, much less 1.1 applications, on the same application pool. I've made sure that EVERYONE can do ANYTHING to the files and directories in the application itself. I understand the security ramifications here, I'm just trying to get it working at all, and then I'll constrain the access rights afterward, one step at a time. But in any case, everyone can read those files.

View 2 Replies

C# - Proper Implementation Of N-layer Architecture?

Feb 28, 2011

I have been learning C# for the last year or so and trying to incorporate best practices along the way. Between StackOverflow and other web resources, I thought I was on the right track to properly separating my concerns, but now I am having some doubts and want to make sure I am going down the right path before I convert my entire website over to this new architecture.

The current website is old ASP VBscript and has a existing database that is pretty ugly (no foreign keys and such) so at least for the first version in .NET I do not want to use and have to learn any ORM tools at this time.

I have the following items that are in separate namespaces and setup so that the UI layer can only see the DTOs and Business layers, and the Data layer can only be seen from the Business layer. Here is a simple example:

[Code]....

Am I completely off base? Should I also have the same properties in my BLL and not pass back DTOs to my UI? what is wrong and what is right. Keep in mind I am not a expert yet.

I would like to implement interfaces to my architecture, but I am still learning how to do that.

View 4 Replies

Proper Implementation Of MVP With Complex Controls?

Jan 20, 2010

I'm currently implementing a project using asp.net, c# and the MVP (Model-View-Presenter) pattern. The main purpose of this solution is to deliver a graph to the consumer, to be used by a variety of systems. It is basically a custom graph server.

The view page in this particular case has an MSChart control on it, which has to be dynamically populated and configured based on parameters in the QueryString. This can be as diverse as totally different types of data sets, display modes and so on, using a lot of the properties of the chart control.

Many of these properties are again of types which are particular to the chart control and would require the same dependencies as the chart control itself if they are to be set by the presenter.

I'm trying to figure out the best way to expose the properties to the presenter so it can work its magic.

Should I:

Just expose the whole chart object and live with a system.web type dependency in the presenter project? Make accessor and translation properties for all of the chart control properties so that I don't have the dependency, but add lots of complexity? Other, that I haven't thought of?

To me it seems that it would be against the MVP pattern to bubble a display control up into the presenter, but it seems that trying to map all the properties to DTOs or similar would be a lot of work that would add a lot of complexity, and while the solution would be somewhat more loosely coupled, I'm not sure the gain would be worth it in this case. How would you implement something like this, given MVP?

View 2 Replies

Proper Way To Build A Data Repository In .NET MVC

Jun 15, 2010

I'm working on using the Repository methodology in my App and I have a very fundamental question.When I build my Model, I have a Data.dbml file and then I'm putting my Repositories in the same folder with it.... IE:

Data.dbml
IUserRepository.cs
UserRepository.cs

Is it better to build the folder structure like that above, or is it ok to simply put my Interface in with the UserRepository.cs?

View 3 Replies

Configuration :: Unable To See Proper Exception In IIS 7.5?

Aug 1, 2010

I am develpoing asp.net web site (3.5) and lately I moved to windows 7. Since then I can't see properly asp.net exceptions and instead of that I'm getting full page with random characters.

View 4 Replies

MVC :: DropDownList And TemplateInfo Not Selecting Proper Value?

Feb 22, 2010

I am having trouble with DropDownList (and/or DropDownListFor) when using TemplateInfo's HtmlFieldPrefix in a strongly-typed view. DropDownList properly selects the value from the model when the prefix hos not been site. Once I set the value of HtmlFieldPrefix, the value from the model is not selected in the drop-down list.

I am using .NET 3.5SP1 and ASP.NET MVC 2 RC2.

Model:

public class TestModel
{
public string Text { get; set; }
public string Option { get; set; }

[Code]....

Is there something I should be doing differently to have the proper value selected in the drop-down list?

View 15 Replies

Check What Is In The Fileupload Is A Proper And Existing File?

Jul 15, 2010

I have on my page a fileUpload control. -

<asp:FileUpload ID="FileUpload1" runat="server" />

and a save button.

When I browse and pick a file and press save the code works fine. However if I manually type rubbish into the fileupload and press save nothing happens.How can I get the save button to work so that I can check what is in the fileupload is a proper and existing file?

View 12 Replies

VS 2005 Proper Updating Of An Existing Website?

Feb 8, 2010

So my application is on a production and running smoothly with no bugs at all. yay! My question: Is there's more efficient way of updating an existing ASP.NET application? Here's what i'm currently doing ( dont laugh that's why im asking xD):

1. I compile the project,
2. after compilation i transfer the compiled files via ftp. then i delete the existing files on my folder and put the newer one.

View 10 Replies

Proper Gridview Alternative - Highly Customizable

May 7, 2010

What is the proper alternative to Gridview in ASP.NET? By proper I mean highly customizable, css and JQuery friendly.

View 1 Replies

Proper Syntax For Embedded Resource Tags?

Aug 26, 2010

I'm trying to localize an asp.net web application. Consider the following asp.net code. I'm running with CurrentCulture and CurrentUICulture set to German ("DE-DE").

<%= ReportTitles.EndOfDay %>
<asp:Literal ID="litLabel" runat="server" Text="<%$ Resources:ReportTitles, EndOfDay %>"/>

I expect these two lines to yield the same result, but instead I get this:

Auswertungen für den Tagesabschluss
End of Day

In other words, the first syntax <%= ReportTitles.EndOfDay %>successfully retrieves the value from the ReportTitles.de.resx file we're using, but the second syntax <asp:Literal ID="litLabel" runat="server" Text="<%$ Resources:ReportTitles, EndOfDay %>"/>
gets the value out of the default US English ReportTitles.resx file.

View 1 Replies

Proper Way To Write A File Path To A Link

Apr 7, 2010

I am able to upload a file to the server into a folder structure. but when I try to link to the file, the image path in the code is giving a strange url.

It should be something like

<a id="GridView1_ctl02_HyperLink1"
href="../MyFiles/1.jpg">HyperLink</a>

but instead its coming back as

<a id="GridView1_ctl02_HyperLink1"
href="../MyFiles/%3C%25#%20Eval(%22filename%22)%20%25%3E">HyperLink</a>

I am using this code to link to the button - which I'm sure is causing the problem

<asp:HyperLink
ID="HyperLink1"
NavigateUrl='~/MyFiles/<%# Eval("filename") %>'
runat="server">HyperLink</asp:HyperLink>

View 2 Replies

C# - Efficient And Proper Linq Queries From Database

Nov 9, 2010

A sample linq query from MSDN: var expensiveInStockProducts = from p in products where p.UnitsInStock > 0 && p.UnitPrice > 3.00M select p; Does this query select EVERY column from the database table immediately, or does it return some sort of pointer that retieves the actual column data on demand? ie. If there are 50 columns in my table and I only use a single p.UnitsInStock in my actual code, then am I retrieving 50 times more data than I expected?

View 2 Replies

Web Forms :: RTL Effect Not Proper On Menu Control?

Dec 23, 2010

I am using an ASP.net menu control on my page. The page direction is changed using "dir" attribute of body/table containing menu control. Every thing works fine but the drop down position of menu control remains on the right side instead of left if changed to rtl. Can anyone suggest way out?? I am more interested in server side script instead of CSS.

View 2 Replies

ADO.NET :: Proper Way To Encode HTML For Linq Insert Into DB

Oct 10, 2010

I've installed a Free TextBox editor to allow clients to do a write up about themselves and style it with HTML. Been reading about cross site script attacks (XSS) and want to make sure I'm correctly uploading the data collected with the Server.encode method.

Is this the right way to do it?:

[code]....

View 2 Replies

Security :: Grant Assembly With Proper Permissions?

Oct 5, 2010

I'm developing a managed module for IIS7. Assembly with my code is placed in GAC and worked fine within 2.0 pipeline. But with .NET 4.0 pipeline (and Medium Trust Level chosen) there are no permissions to read registry and code is unable to read/write

"C:Program Files<Folder>MyAppConfig.file"

Is there any way to grant my assembly with proper permissions to do this?

View 3 Replies

Trying To Create A Proper Directory Structure For A New Website?

Jul 9, 2010

Can you point me to a url for the proper directory structure to create for a new website?I can create a website project and add class library projects to the solution to create a fully functional website.My grey area is that I need to zip up the web site solution and hand it over to the client.I'd like to make sure that I hand over a solution with the most proper directory structure.I'll run you through a scenario:

1. Select File > New > Web Site > ASP.NET Web Site from the main menu
2. Save with a path of C:ProjectsTestWebSite
3. Right-click the solution in VS and select Add > New Project > Class Library
4. The new class library is added with an automatic path of C:ProjectsTestWebSite (2)MyClassLib1

It seems like there should be a way to create a better structure for this but I'm just not following the correct process. Can you point me to a url with instructions for managing a proper structure for this?

View 1 Replies

C# - Proper Procedure To Create A N-tier Website?

Dec 8, 2010

What is the correct procedure to create an n-tier Website in ASP.NET? Can this be done without setting up a server farm, and how would you be able to test it?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved