I m having little misunderstanding that how basepage inheritance work in asp.net. I saw this example [URL] and others and I just have questions to get better understanding on the articles: Do we always need override type function in base page even if we dont want to overwrite in child page. What is the purpose of "MyBase.OnLoad(e)"?
' -- VB.NET Public Class MyBaseClass Inherits System.Web.UI.Page Protected Overrides Sub OnLoad(ByVal e As EventArgs) '... add custom logic here ... 'Be sure to call the base class's OnLoad method! MyBase.OnLoad(e) End Sub End Class
Take the following scenario. I have multiple ASPX pages. Login, Logout, Main, Messages, etc... They all inherit from System.Web.UI.Page of course. For all the pages, I want to override the Render method from the Page class. I could easily copy and paste the same code into each page like so:
protected override void Render(HtmlTextWriter writer) { //Code Logic Here }
But if I had many pages, lets say 20, maintaining the code in each page could get very time consuming and error prone.That made me think a bit and I thought okay lets try this...override the function in each page but call a static function. That way changing the static function would result in a change for every page.Which works fine... But its not really nice and clean, having to override like that on every single page.
I am attempting to inherit an ASP.NET RegularExpressionValidator and add some functionality to it. I inherited the control and added my custom properties. However, I would also like the client-side functionality to call a different JavaScript functionIn order to do that, I will need to supress what is happening in the AddAttributesToRender method because the name of the function is hard-coded there.
Protected Overrides Sub AddAttributesToRender(ByVal writer As HtmlTextWriter) MyBase.AddAttributesToRender(writer) If MyBase.RenderUplevel Then Dim clientID As String = Me.ClientID [code]...
I have created a usercontrol to capture education details, it contains 5 textboxes and an functionto insert that values into my db. I have added the usercontrol 5 times to a page. I have a button on my aspx page which I want to be able to click and call the function to insert the values.
I have a usercontrol on the content page. I'm trying to access this usercontrol's hiddenfield.
I was able to access it before applying the master Page. But once I changed the page to a content page , the value in the hiddenfield is showing empty.
alert(document.getElementById('<%=hidLat.clientID%>').value) is showing the value.
I have a property PickupHidLat defined on the ascx page and I'm using this property to access hidLat value on the content page.
How can i make my own delete method to prevent that the data really gets deleted? i want to set a datetime field when it gets deleted insted of a normal delete. i read about overriding the submitchanges function, but i don't get it to work
A menu control 2 levels deep does not play well with internet explorer on https.
I continually get an annoying popup.
I think in order to fix this I need to override a function in an automatically included script file.
change this
function PopOut_Show(panelId, hideScrollers, data) { ... childFrame.src = (data.iframeUrl ? data.iframeUrl : "about:blank"); ... } to this
function PopOut_Show(panelId, hideScrollers, data) { ... if(data.iframeUrl) childFrame.src = data.iframeUrl; ... } however I have no clue how I would hack apart the asp:menu control to fix microsoft's javascript in their control.
Is there a way I can just override the function to what I need it to be?
how can i call javascript function from code behind from my Page.aspx.vb. in my Page i have a button i want to add this function to my button onclick="refreshParent();"
I'm creating a multi-tenant Asp.Net MVC 3 Web app, and using EF4.1 code first for the db model.For development I'm happy to use SqlServerCE in App_Data, and for production this will move to Sql Server 2008.
Say my context is called "MyModels", by default code-first looks for a connection string called "MyModels" in Web.config. This can be told to use a file in App_Data or changed to access a database in SQL2008. All fine so far.
But because of multi-tenancy, I'd like the SqlServerCE filename to match the unique id of the tenant (so App_Data would have "client_x.sdf", "client_y.sdf"; Sql Server 2008 would have separate databases). I can't work out how to direct to these different databases.
I've tried MyModels inheriting from DbContext and supplying a connection string (using a 'placeholder' conn string in Web.config and replacing "{clientId}" with the unique id), and I've also tried setting the connection string in the MyModels constructor:
base.Database.Connection.ConnectionString = xxx;
but this never seems to work. I always get the following error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
( it's not yet 'configured' to use SqlServerCE, and so is trying to connect to Sql Server)
Tracing the code, Database.Connection.ConnectionString hasn't been read from Web.config at this point, so I can't search and replace that, and, possibly, it's getting overwritten by the 'placeholder' conn string later in the pipeline.I reckon this must be quite straightforward and I just can't find the 'hook'.
I want to add a class and initialize a JS funcion behind my nested masterpage which is being dervised from an other master page. But when I add the following code in the PageLoade event in the code behined of my derived page then it give the folowing error
Exception Details:
System.NullReferenceException: Object reference not set to an instance of an object.
If I were to specify a page for redirect using the ASP.NET Custom Errors feature, would my application still spit out the HTTP status code for that particular error?
For example if had a line in my web.config that had all Internal Server Errors redirect to Errors/500.aspx and then I encountered a 500 error, I would then be redirected to my custom Errors/500.aspx page. Will my application still respond with a HTTP 500 at any point in this exchange?
I need to trigger a C# code behind function right after an ASP.NET page is completely displayed. Is there an event to program? If not, do how to do it?
Can someone explain to me the rules around what can and cannot be evaluated/inserted into markup using the <%# %> and <%= %> tags in asp.net?When I first discovered I could inject code-behind variables into mark-up using <%= I thought 'great'. Then I discovered that if such tags are present you can then not add to the controls collection of the page (that's a whole different question!). But <%# tags are ok.
Is there a way I can inject a code-behind variable or function evaluation into the page using <%# ?
I am trying to call a web service function within my own ASP.net (code behind) using AJAX on the page.
Once i push the button to execute the JS/AJAX/codebehind - I got an error.
POST http://************/admin/Admin.aspx/getDBInformation 500 (Internal Server Error)
This is my code below that I am currently using:
Code: <WebMethod> _ Public Shared Function getDBInformation() As String loadDBData() Return JsonConvert.SerializeObject(dbInfo, System.Xml.Formatting.Indented) End Function End Class
I have all my site navigation done in my master page. However, I have one page where if they make changes I set a set a flag that I want to use makes them save or cancel the changes before they can navigate away from the page. How do I go about for just that single page overriding the Master Page navigation events?
I am working with a third party asp.net application that uses master pages and nested master pages. My needs are to dynamically set the master page files for each page(.aspx). The application by default sets the master page file in the strongly typed @Page directive for each page. I don't want to change the strongly typed directive on each page (over 50 pages) because I am lazy and I want to minimize conflicts with future upgrades.