VS 2008 - Main.Master Page Not Reading Web.config File?
Nov 2, 2010
I have a website written in C# that was running fine on one server. We moved it to another server and have a couple issues. I am mainly a VB.NET coder but can do a few things in C#. This is not a project - it is a website and can open it in VS2008 no problem. This is an admin site for the whole website where the user can add customer comments, etc. When logging in, it works fine. I can go to one of the admin pages after logging in and works. If I go to two other different pages, I get this error:
Object reference not set to an instance of an object.
[Code]....
It turns out this is in the main.master page and it is used by the other pages that load fine. The ApplicationTitle variable is set right in the web.config file and like I said, it shows on the other pages.
My question is why would this code work fine for some pages and not two others? All of these admin pages are under a folder called Admin and the web.config file is in the root folder of the website. Its almost like these two pages cannot see the web.config file in the root folder? Why would that be if thats the case?
Btw, when I have this loaded in VS2008 and try to do a Build, it says:
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
I would assume the folders on the server are set right since all but two .aspx pages run fine. Just something I thought I would mention. This does not really seem to be a coding issue but something not set right especially since it ran on the other server just fine.
I would like to put a value in web.config file in my project and read it programatically from .aspx page.Under which section of web.config file should I save the value. This is not a connectionstring. It is path of a file. And I how can programmatically read the value in the code?I am using C#.
I'm trying to dynamically change the look of my main master page depending on what nested master page that the current content page is using .
So for example.
Main master page = main.master My nested page = nested.master (uses main.master) content page = content.aspx (uses nested.master)
So in the Page_Load event of main.master I want to add a switch statement that will check to see what nested master page is currently being used by content.aspx, or whatever content page is loaded.
So far I have got
protected void Page_Load(object sender, EventArgs e) { string nMaster = //This is the line of code that I am looking for. switch(master) { case "nested.master": //all my logic here. break; } }
My asp.net app has is using a web.config for common configuration. I also have a section that maps some data objects to connection strings, and that section is going to be couple thousand of lines. I want to move that section to another config file "dataMappings.config", so I don't bulk up web.config - is there a standard mechanism of accessing that config file?
I a custom config file which I am having problems reading from a class project, is there a simple way to do this? the path does not seem to be getting picked up in code, where as this works in a web project
I have code that reads a value from a config file (not web.config) given a key. It looks like this:
Code: Public Shared Function GetCustomConfig(ByVal ValuetoGet As String, ByVal ConfigFileValue As String) As String Dim Returnvalue As String = String.Empty LoadConfig(ConfigFileValue) For Each KeyValue As String In AppSettings.Keys If KeyValue = ValuetoGet Then Returnvalue = AppSettings.Item(KeyValue).ToString End If Next
Return Returnvalue End Function
So if my config file which is named my.config has this entry: <add key="TempArea" value="c:Temp"/>I would call GetCustomerConfig("TempArea", "my.config") and the function would return "c:Temp". Most of the time this is what happens. But sometimes I get an exception: Collection was modified after the enumerator was instantiated.
Is there a better way to get the value given the key? This is code written long ago by my predecessor, and I am not sure I want to use it anymore. If I do use it, I will have to do something so that it is more reliable.
I have created a demo application to read data from the CSV and after read the data from the csv file there is a button to save all the CSV loaded data in the database. When i load the large CSV (2MB) file . after load all the data from the file i will save all the data in datatable and store in view state.
when i click on another Link the page doesn't work and page become expires. Where is the problem.
Its simple doing read CSV file .. file stream closed. store all the csv data in view state. and click on the another link save into the database. but click save database button page expire.
how to read the data's in the text file using sql server 2000 and 2008. i have a text file in a server and it contains one column name with the multiple column values i need to read that informations and i need to update in a table in the database.
I'm trying to read the contents of a text file into a text box on my form. When I run the following code, nothing happens.
VB.NET Code: Protected Sub lbLogs_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles lbLogs.SelectedIndexChanged For Each li As ListItem In lbLogs.Items If li.Selected Then Using sw As New StreamReader(li.Value) txtLog.Text = sw.ReadToEnd sw.Close() End Using End If Next End Sub
I populate the ListBox with ListItems and each ListItem's Value property holds the full path to the file. But, I removed all of that and just put txtLog.Text = "test" inside of the "is selected" block.
I would like to use both of the connection strings in the same web.config file how can I do this I tried this yesterday it worked I called it a night, then this morning I got this. The error being on line: 10 Parser Error Message: The entry 'ApplicationServices' has already been added.
Line 8: <add name="ApplicationServices" Line 9: connectionString="Data Source=Mysource;Initial Catalog=travelatlantic;User ID=MyID; Password=MyPassword;" /> Line 10: <add name="ApplicationServices" Line 11: connectionString="Data Source=MySource;Initial Catalog=travelatlantic2;User ID=Myid; Password=MyPassword;" /> Line 12: </connectionStrings>
I know this is probably a pretty easy thing to do and it is if I can upload the file and store it onto the hard drive of the server. What I need to do is read the text file into memory and then parse through it one line at a time. Anyone have any code that demonstrates that?
I am working on masterPage/sub masterpages, all worked fine until this morning.When I open a .aspx which uses masterpages, in the design view it shows the error message..
I've checked both master pages several times, all tags are matched and visual stuido itself doesn't indicate any errors. Also in debug mode the html page is generated without any problems..
My computer system froze on me, the mouse froze, cntrl-alt-del, did nothing, so I reset it. Did a disk check, and now everything seems fine except for my master Page html code which I was in the middle of editing when it happened. The VB code-behind file is still ok, the designer file still shows ok with all of the controls in it, but I can't get into desgn or source view. It just opens and gives a whole page of hesixecimal code such as as:
I have some code that reads records from an excel file and then imports that data into an sql database. The issue only happens when the excel file has more then 350 rows in it. In the middle of the import it just stops executing and I get directed to the 'Internet Explorer cannot display the webpage' page or just a blank page when using firefox.
I dont get any time out errors or any error at all but still I tried messing around with the script timeout settings but still does the same thing at about the 2 min 30 sec mark.
I understand how to use a connection string object to read excel sheets. What I don't know is how to follow a hyperlink inside excel, grab matching data from the linked page and return it to my database. Essentially, the spreadsheet has two columns:
Title | Class#
Class# has the hyperlink which links to an internal web site. The connected page has a course description and any pre-required classes that must be taken before you can take this class. This is where I'm rather stumped as I've not had to do this type of thing before.
But when i go to Design View of the page (for creating the events automatically or for drag/drop any new control from toolbox, I don't want to type everything) the design view only shows the master page! the page controls are complete ignored!
This is the content in the master page as you can see there are 4 menu items i tried to form as sidebar and i tried to inherit in home.aspx(one of the content pages) as follows:
But unfortunately the sidebar is not at all getting displayed. I know i'm doing fundamentally wrong some where. My intention is to have web pages to have sidebar like this. It is a screenshot of my intended page.
From my main window I am clicking on a button to show a popup window with a gridview control in it. I want to click on a row of the gridview and pass that date back to the main browser and have the gridview load data based on that value with the sqldatasource control. Is there any way to pass a value back and make it postback?
How can I bind my menucontrol on my master page code behind? this is my code i've been fiddling with but my menu object is always nothing. what am i doing wrong? I have a menu control with ID=sitemenu on my master page
I had archived all of my files prior to the change. Since I am now having a great deal of trouble working with 2010, I want to revert. My question is: If I restore all of the archived files and start 2008, will I need to make any changes to the registry or to any other files?
The problems that I am having are illusive. Some of the relative paths nolonger work. Some f the projects that had been working for 24 months no longer functions. I am having a great deal of trouble calling my older "[WebMethod]" "ASMX" services and many other issues.
I am using BlogEngine.net and just created a theme (site.master) file and works but when I add a literal control and try to call a function from App_Code I get a 'Compiler Error Message: BC30002: Type 'basicFunctions' is not defined.' error. I call functions from basic_functions.vb in normal .aspx pages at the root. Since my error page is in a subfolder that has it's own App_Code folder, do I have to do something different?