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


Top 5 Contributors of the Month
MarieAdela
Imran Ghani
Post New Web Links

Cannot access public methods on MasterPage

Posted By:      Posted Date: September 09, 2010    Points: 0   Category :ASP.Net
 
Hi All, maybe someone can help me with this one. I have a a public method in my code behind on the site.master pagenamespace PROJECT { public partial class Site : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { } public void applyUserRole(string userID) { } } } I  wish to call applyUserRole() from Default.aspx On Default.aspx I have .. <%@ Page Language="C#" MasterPageFile="Site.Master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Project- Home" %> <%@ MasterType virtualPath="~/Site.master" %> But when I go to Default.aspx.cs and type Master. the method is not appearing. I've seen other post where people are having this issue but I can't find an answer. If anyone has any good pointer and you please let me know, thanks 


View Complete Post


More Related Resource Links

Access Public Function in MasterPage

  
Hi,I need help in accessing the function in my masterpage.I have a.master and b.aspx with the content page.Now in the page load of my content page, I want to execute the an sql query which is in a function in my master page.How can I access the function in my master page??code in my master page:public function info () as string'SQL Queryend function

ASP.NET MVC: Using NonActionAttribute to restrict access to public methods of controller

  
 

Public non-action methods in ASP.NET MVC controllers are source of problems because they can be called by user when not handled carefully. Same time you may need public methods on controllers for some other reasons (some UI framework, testability problems, things you cannot change etc). In this posting I will show you how to handle controller methods properly.

Calling controller methods

Public methods of controller are called controller actions and these actions are mapped to URL-s using routes. Take a look at the following code.


public Acti

is there any impact of using static methods in Business Access layer in 3 tier applciation

  

is there any impact of using static methods in Business Access layer in 3 tier applciation,


Please suggest me what are the best practices and standards


Not able to access Class methods when deployed on a remote server?

  
I have a web service project. In the project I have a class named "Piper"In testing the web service in localhost mode in the VS IDE, I can access membersof the class, such as my method "Proceed" and property "Comber" The problem I am having is that when the web service is deployed to the serverin staging, or the deployment server, I am not able to access any methods of my class. Onlythe properties. This is very strange? As they are both public and I can access them when I run the project in local host in the IDE. Does anyone know what the problem might be?Here is a simplified example of my class. Public Class Piper Public Sub Proceed() End Sub Public Property Comber() As Boolean  Get   Return True  End Get  Set(ByVal value As Boolean)       _comber = value  End SetEnd Property End Class

Need help: "Adding Parameterized Methods to the Data Access Layer"

  
Hi all, em all new in C# and .NET.I am following this tutorial: http://www.asp.net/data-access/tutorials/creating-a-data-access-layer-csAnd i am at step 3: Adding Parameterized Methods to the Data Access Layer - i have No problems in getting out all information from my database.But when i try to get a specific item by CategoryID i get a Error.This is what i type in my Query in the table adapter:SELECT     ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, DiscontinuedFROM         ProductsWHERE CategoryID = @CategoryIDHere is the error i get when i click finish:The wizard detected the following problems when configuring TableAdapter Query "FillByCategoryID":Details:             Generated SELECT statement.              Error in WHERE clause near '@'.              Unable to parse query text.Can anyone help me with this problem?Someone who knows what i am doing wrong?Thanks

access control from masterpage

  
How do I get access to the below linkButton control from my Master page or a page using that Master, this is in my Master page:<Project:RoleControl ID="RoleControl1" runat="server"> <AdminTemplate> <li id="liadmin" runat="server"><asp:LinkButton id="lnkAdmin" PostBackUrl="~/admin/admin.aspx" runat="server" CausesValidation="false">Admin</asp:LinkButton></li> </AdminTemplate> </ Project:RoleControl> Basically it's a custom control I built which will allow me to show certain things only to admin users, we are not using asp.net membership so I came up with a control that works. But when I try to access it within the Master page itself it keeps saying the control has 0 count in it, I'm doing this check in the Page_Load event:if (RoleControl1.Controls.Count > 0) { string roleControlId = RoleControl1.Controls[0].ID; ((HtmlGenericControl)RoleControl1.FindControl(roleControlId)).Attributes["class"] = "navselected"; } But the RoleControl1.Controls.Count check is always 0. I know the control is rendering as I can see it when the page loads, the link comes up. I thought maybe I'm checking it in the incorrect event, rather than Page_Load should I be checking for it in another event, could it be that at that point

public web methods...how to make private? Security question

  

I understand how to set security for a ASP.NET web page, how to encrypt a Silverlight page, and a WCF application, but my question goes to this:  given a web method, which by definition must be public, how do you keep people from accessing it outside of your client program?


If your program (client) is the only way to access this web method, then there's no problem.  But it is impossible to make a web method private--it won't compile--so how to keep people from using it?  The only thing I can think of is that if you call your web method by an obscure sounding name, it's likely nobody will guess the URL, and if you set your server so it cannot be searched (dir *.*) by the public, it's unlikely anybody will ever guess the name of the web method.  But this is hardly 100% secure.  And what if you call your web method "DoWork", which is the default OperationContract name in Visual Studio?

What am I missing?


PatHens

 

//what I have in mind

public interface IService1
    {
        [OperationContract]
        string DoWork();
}

//

public string DoWork()
        {
//secret stuff in here
string SecretStuff = "S

Public Access to Reports

  

I'm designing some reports to summarize recently compiled research findings.  These reports are going to be posted on an ASP.NET page (via the report control) on the web site.  I do not want to authenticate users, as the findings are meant to be public and requiring users to register and authenticate would add a barrier and is likely to decrease traffic.

I've seen similar posts where reports are meant to be viewed by everyone on an intranet and permissions could be set using a designated workgroup.  I need alternative solutions to the problem of making a report viewable by everyone who visits a site.  I'm also currently unfamiliar with Kerberos (and I know that will probably pop up as a potential solution), so if there's a convenient way outside of that it would be great.


Public Access to SSRS Reports

  

I'm designing some reports to summarize recently compiled research findings.  These reports are going to be posted on an ASP.NET page (via the report control) on the web site.  I do not want to authenticate users, as the findings are meant to be public and requiring users to register and authenticate would add a barrier and is likely to decrease traffic.

I've seen similar posts where reports are meant to be viewed by everyone on an intranet and permissions could be set using a designated workgroup.  I need alternative solutions to the problem of making a report viewable by everyone who visits a site.  I'm also currently unfamiliar with Kerberos (and I know that will probably pop up as a potential solution), so if there's a convenient way outside of that it would be great.


How to access methods in one service contract with different bindings?

  

Hi,

Here i explain my exact problem. I have one service contract.

 [ServiceContract()]
 public interface IParcel
{
 [OperationContract()]
 ParcelList GetAllParcelData(string countyId, string year, string parcelId);
 [OperationContract()]
 ParcelList GetParcelDataByParcelId(string parcelId);
 [OperationContract()]
 [WebInvoke(UriTemplate = "/Search/", RequestFormat = WebMessageFormat.Json,
  ResponseFormat = WebMessageFormat.Json)]
 SearchParcelList GetSearchParcelDetails(SearchParcel parcelNumbers);
 }

My requirement is, i have to make "GetAllParcelData" method access by using wsHttpBinding,  "GetParcelDataByParcelId" using some other binding like net.tcp.binding and "GetSearchParcelDetails" using webHttpBinding. This one i have to make restful method.

means the methods inside one service contact have to used different bindings to access.

finally, i need to know is this type secnario possible. if yes explained with example.

Thanks in advance.......


Matching C# methods with a pattern finding the Public, Private, etc modifiers and balancing the curl

  

Hello all,

For a large conversion project, we need to match certain key words within C# methods and remove the entire method if found. I know .Net has a feature that allows balanced matching on the curly braces, but I am not sure how to implement it.

In a two step process, you could match the modifiers Public, Private, etc and their balanced curly braces to identify the methods and then remove those that contained the key words. In a one step process, I think you could use a positive lookahead for the key words as well.

Could someone help me with the pattern that has the balanced curly brace logic with the modifiers to identify the methods? Thanks in advance for any ideas and/or suggestions.

 


Have a great day!

Restrict public access to webservice

  

I have this Internet web service page(webservice.asmx) being consumed jquery ajax call.

And I am hoping to restrict public request to this webservice other than request from local pages (aspx or jquery ajax call).

The web service checks for form-authentication before it gets executed but I just don't feel comfortable the .asmx page and list of services are viewable.

So users can't just type www.mysite.com/webservice.asmx to access my webservice. 

I'd appreciate any advice about securing web service.



No access to DbSet methods (Add, Find etc.)

  

Hello,

I found a really nice tutorial http://msdn.microsoft.com/en-us/data/gg685489 and started to create simple MVC3 application with EntityFramework 4.1. I almost repeated steps in that article - created an MVC 3 application, added ADO.NET Entity Data Model (generated from database in SQL Server). I didn't use ADO.NET DbContext Generator, I created classes manually. When creating controller I wanted to use Find and Add methods, as described in tutorial but they were not recognized and I got errors. Does anyone know what can be the reason?

Many thanks!


The Decorator Pattern & Extension Methods

  
The decorator pattern provides a formal way to add new functionality to an existing type, without sub-classing. First question: What is wrong with classical inheritance? In and of itself, nothing is wrong with the good old Is-A relationship. It is very common to derive a new class from an existing base class in order to override a few virtual members, and add a pinch of new functionality.

Using jQuery to directly call ASP.NET AJAX page methods

  
Here I am looking to explain how to call page methods using jQuery. Using jQuery to directly call ASP.NET AJAX page methods

MVC architecture in ASP.Net using C# and Microsoft Data Access Application block

  
The Model-View-Controller (MVC) pattern separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes [Burbeck92]:

Model. The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).

View. The view manages the display of information.

Controller. The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate.

The Decorator Pattern & Extension Methods

  
Numerous design patterns exist in the software world today, and ultimately nothing is preventing you from making your own (if people buy into it or not is another question). Furthermore, there is no 'master list' of patterns that all developers agree upon. While this is true, if you pick up any book on the subject, you will find a set of very common patterns most programmers agree are very useful. Many of these patterns were first formalized in the seminal book on the subject, Design Patterns: Elements of Reusable Object-Oriented Software (aka, the Gang of Four [GOF] book; not to be confused with the UK punk band of the same name).
Categories: 
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