Is There A Method That Returns A System.Web.UI.Page Class Given An URL?
Apr 17, 2010
I'd like to be able to determine what class will be called given an URL. For instance, I have a page /First.aspx that has a hyperlink to /Second.aspx In the code behind for First.aspx.cs, I'd like to be able to determine what class will execute if someone clicks on the hyperlink that points to /Second.aspx.
EDIT: One of the reponders asked me to outline the problem I'm trying to address. Here it is: The codebase I inherited has a subclass the System.Web.UI.Page that has a public Authorized method that returns a boolean. The Authorized method checks the parameters passed via the query string against the authenticated user, and determines whether that user should be allowed to call that page with the given parameters.
Elsewhere in the site I have hyperlinks that reference those protected pages. In some instances those links are displayed to users who are not authorized to navigate to that page. They can click the link, however they get an error. In other instances, prior developers when through the trouble of inserting logic that hides the hyperlink for those unauthorized users, but the authorization logic is duplicated (In the page itself, and in the linking page). What I would like to do is create a subclass of the hyperlink class, and have the subclass inspect the NavigateUrl, determine the destination page class, and call the Authorized method of that class to determine if the user is authorized to call that page. If the user is not authorize, the link will automatically hide itself.
View 2 Replies
Similar Messages:
Apr 27, 2016
This is the query I am running in DB:
select UM.USER_NAME, RM.ROLE_ID, RM.ROLE_NAME
FROM [MICommonDB].[dbo].[ROLE_USER_MAPPING] as RUM
join [MICommonDB].[dbo].[ROLE_MASTER] as RM ON RM.ROLE_ID=RUM.ROLE_ID
join [MICommonDB].[dbo].[USER_MASTER] UM ON UM.USER_ID = RUM.USER_ID
where UM.USER_NAME='useruser'
which is giving me proper result(i.e., 2 records) when running in SQL server.
Now I have created below method in a class with same query (I am calling this method inside Controller):
public IEnumerable<RoleUserDO> getRoleNameByUserName(string userName)
{
IEnumerable<RoleUserDO> strResult = null;
strResult = (from RUM in oDBContext.ROLE_USER_MAPPING
[CODE]..
but it returns only 1 record instead of 2 records(when compared with DB query)
View 1 Replies
Feb 1, 2010
We have a Page Method on a web page using ASP .Net. We tried to put in a trace statement using both System.Diagnostics and System.Diagnostics.Debug. In Visual Studio 2008, the break point is not even hit for the line, but other break points on other lines are hit.There is no output from either method that we can see.
There is also a Global.asax error catcher that works fine in other cases, but in the Page Method is not being catched.why a Page Method and System.Diagnostics do not play well together?
View 1 Replies
May 20, 2010
When I move some web-based code from VS2008 to VS2010, I find it is different when it is hard to handle the Image class.
Let's take the following code as an example.
[Code]....
As I have already imported the System.Drawing namespace, I still cannot use Image.FromFile method as VS2010 detectss the Image class is in System.Web.UI.WebControls namespace.I have lots of such a kind of code in my project using Image class and I will get messed if need to modify the code from
[Code]....
Since I also used image in my variable name.
View 2 Replies
Oct 25, 2010
I am to access a method on my master page. I have an error label which I want to update based on error messages I get from my site.
public string ErrorText
{
get { return this.infoLabel.Text; }
set { this.infoLabel.Text = value; }
}
How can I access this from my user control or classes that I set up?
View 3 Replies
May 21, 2010
public partial class _Default : System.Web.UI.Page
View 3 Replies
Jul 27, 2010
I have the following method in a class withing a website.
public static void Authorise(int role, Page callingPage)
{
callingPage.Master.FindControl("divUnauthorised").Visible = true;
callingPage.Master.FindControl("ContentPlaceHolder2").Visible = false;
}
Now this works fine but I really want to just have the one parameter of role and not require the page to pass itself into the method. Is there a way of finding the object that called the method and casting it to a System.Web.UI.Page?
View 2 Replies
Jan 27, 2010
I have a project that it had been developed under MVC1 and after aa few months ago I upgraded it in MVC2.
Everything was well, uppon the day I needed to format my computer.
And what can goes wrong with a format? I don't know
I have installed the MVC2, I build the project, no error displayed, but from the time I've uploaded the project in the production server
I am getting this error.
Method not found: 'System.Web.Mvc.MvcHtmlString System.Web.Mvc.Html.LinkExtensions.RouteLink(System.Web.Mvc.HtmlHelper, System.String, System.Object)'.
I can't understand what caused the problem.
Certainly I assumed that is have to do with MVC1 and I referenced it, but with no luck
again.
Theese are the methods that the problem is came from
[Code]....
View 15 Replies
Oct 18, 2010
I have an ObjectDataSource that I want to perform updates using a business entity i.e. Type="Object"). Since the values for the entity are within a user control, I have stored a reference to the control in Session and in the updating event, set the new instance to the value of the entity from the user contol property (which also pulls values from the form viaother properties of the control):
Protected Sub MasterDataSource_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles MasterDataSource.Updating
Dim entity As New Login()
Dim accountControl As AccountInfo = TryCast(Session("AccountCtrl"), AccountInfo)
entity = accountControl.Entity
e.InputParameters.Add("entity", entity)
End Sub
And here's the markup for the datasource:
<asp:ObjectDataSource ID="MasterDataSource" runat="server" EnableCaching="true" CacheDuration="10"
SelectMethod="SelectAll" UpdateMethod="Update" TypeName="Data.DAL.LoginDAL">
</asp:ObjectDataSource>
My question is, how can I get the update method to pass this entity to the update method in my BLL class? It seems the Update method requires an ID or reference to the original object to use in determining whether any changes have taken place, but I don't really want to do this. In other words, I just want to use the Update event on my ObjectDataSource to pass my entity to the method ("Update") I set as a property and then let this business method handle the update of the data. Shown below, is the BLL update method I want to call:
Public Overloads Function Update(ByVal entity As Login)
If entity Is Nothing Then
Throw New ArgumentNullException("entity")
End If
MyBase.Update("UpdateLogin", entity.Username, entity.Password, entity.FirstName, entity.LastName, entity.Role, entity.Region, _
entity.Email, entity.Title, entity.TierID, entity.Street, entity.City, entity.State, entity.Zip, entity.Mobile, entity.Phone, entity.Fax)
End Function
When I try to call this as it stands now, I get an error: ObjectDataSource 'MasterDataSource' could not find a non-generic method 'Update' that has parameters: ID, entity. Previously, I'd set up a long list of parameters of basic data types (string, int, boolean), but this is rather cumbersome and I was hoping to use an entity for this (FYI, I also got the same type of error when I tried this approach, but with the ID as the
last parameter in the list). Perhaps what I'm doing here is atypical to how the ODS is normally used?? Has anyone done something like this successfully?
View 1 Replies
Jan 16, 2011
I've an EntityCollection< T > which contains an element but the Contains method returns false.
I've overriden T's 'Equals' method but the 'Contains' method does not call it (while it's said so in documentation).
When I do foreach (T x in coll), x.Equals(element) returns true.
code:
contains(object entCol, object val)
{
var coll = (ICollection<GraphicSockets>)entCol;
var socket = val as GraphicSockets;
foreach (GraphicSockets sock in coll)
socket.Equals(sock); //true for first element, GraphicSocket's Equals function called
coll.Contains(socket);//false, Equals function not called}
the code i'd actually like to use is
private static bool contains(object entCol, object val)
{
Type entColType = typeof(EntityCollection<>).MakeGenericType(val.GetType());
MethodInfo contains = entColType.GetMethod("Contains");
return (bool)contains.Invoke(entCol, new object[] { val });
}
this worked once but stopped when i started using wcf, i wonder how this contains method works.....
View 2 Replies
Oct 5, 2010
How can I to use System.Drawing.Bitmap class into athoer class?
using System.Data;
using System.Collections;
using System.Globalization;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
namespace University
{
public class Class1
{
System.Drawing.Bitmap BMP=new System.Drawing .Bitmap();
}
}
when I use System.Drawing.Bitmap gives error this class does not exists
View 2 Replies
Oct 26, 2010
This is what I'm trying to run:
[Code]....
When I browse to www.mysite.com/mycontroller/myaction/myid, everything works ok. But visiting www.mysite.com/mycontroller/myaction produces:Server Error in '/' Application.Object reference not set to an instance of an object.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
View 3 Replies
May 12, 2010
I have the following page
[Code]....
Currently, only GenericOfflineCommentary's ExtractPageData() is firing. How can I modify this to first run OfflineFactsheetBase's ExtractPageData() and then GenericOfflineCommentary's?
edit: I'm trying to avoid having to call base.ExtractPageData() in every implementor.
View 2 Replies
Aug 26, 2010
i have two data tables with the same structure
the first one has one row of the second one
the second one has set of rows
what i want is to get the row which comes next to the row of the first data table in the second data table.
the first data table his name is :: temp
the second data table his name is :: dt
i do the following:
DataTable temp = new DataTable();
temp = dt.Clone();
DataColumn[] keyColumn = new DataColumn[1];
keyColumn[0] = temp.Columns["photoId"];
temp.PrimaryKey = keyColumn;
temp = (DataTable)(Session["currentImage"]);
DataRow[] drr = new DataRow[1];
index = dt.Rows.IndexOf(temp.Rows[0]);
but the index always comes with one value = -1
although the temp.rows[0] its contents changed all the time
when i write dt.Rows.IndexOf(dt.Rows[1]) for examble i get 1
but this is not what i want to do ,, what i want to do exactly is to get the datarow next to the datarow of the first dataTable in the second dataTable
View 2 Replies
Feb 19, 2010
had used ajax.method in my project & its working fine, but now Every Ajax.Method returns null now,
View 1 Replies
Apr 21, 2010
I'm trying to encrypt some userData to create my own custom IPrincipal and IIdentity objects using Forms authentication - I've serialized an object representing my logged in user to Json and created my FormsAuthentication ticket like so:
string user_item = GetJsonOfLoggedinUser();/*get JSON representation of my logged in user*/
System.Web.Security.FormsAuthenticationTicket ticket =
new System.Web.Security.FormsAuthenticationTicket(1,
WAM.Utilities.SessionHelper.LoggedInEmployee.F_NAME + " "
+ WAM.Utilities.SessionHelper.LoggedInEmployee.L_NAME,
DateTime.Now, DateTime.Now.AddMinutes(30), false, user_item);
string encrypted_ticket = System.Web.Security.FormsAuthentication.Encrypt(ticket);
HttpCookie auth_cookie =
new HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName, encrypted_ticket);
Response.Cookies.Add(auth_cookie);
However, the string encrypted_ticket is always null. Is there a limit on the length of the user_item string?
View 1 Replies
Feb 19, 2010
I a method that generates a PDF and the method returns a byte value, but after response.end statement, the shows an error that the "File does not begin with '%PDF-' here is the code:
[Code]....
[Code]....
View 2 Replies
Mar 11, 2010
I have a ListView control and under ItemTemplate I have following code:
Code:
<asp:Label ID="Label1" runat="server" Text='<% #MatchCategory(dtCategories.Rows[i]["ID"].ToString().Trim(), Eval("CategoryID").ToString()) %>'></asp:Label>
The MatchCategory method just checks if two values are equal and return true or false. Just below this code I am separately printing dtCategories.Rows[i]["ID"].ToString().Trim() and Eval("CategoryID")
acan see matching values but MatchCategory method always returns false.
View 5 Replies
Jun 24, 2010
I have a WindowsForm that has a DataGridView that shows output of my app. The class with the button is DriveRecursion_Results.cs. I want it so that once the button is pushed by the user, my method FileCleanUp() in my SanitizeFileNames class is called. I'm not quite sure how to do this though.Here is the code for both classes:
public partial class DriveRecursion_Results : Form
public DriveRecursion_Results()
InitializeComponent();
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
[code]...
View 1 Replies
Feb 15, 2011
[Code]....
If I use $get, it does work as the expected functionality for $get. It is only $find that does not work.
Can anyone explain the problem?
View 5 Replies
Jan 29, 2010
I have developed a web application 3 months ago to show facebook users by searching username. To access facebook, I have downloaded facebook dll and got application key, and secret key from facebook. My web application was working fine and displaying records from facebook. yesterday onwards, my application is not working fine. I could not get response when I search by name. I have tested the fql in the facebook testAPI tool online. That time i can get response. but the same fql i used in my appliation but it could not get response from facebook when I search by name. If i search by uid i can get response from facebook. here is my code.
facebook.Components.FacebookService fb = new FacebookService();
fb.ApplicationKey = "bfeefa69afdfe81975f0d6136ace3009";
fb.Secret = "9b672d682e1d8befd06382953fc2615b";
fb.IsDesktopApplication = false;
//the below fql gives response as xml.
//select name, profile_url from user where uid = '1730923544' -I can get response for this fql.
//the below fql does not give response as xml. But it gives empty string.
//the below fql does gives us response as xml when i try in facebook testAPI.
//select name, profile_url from user where name = 'Suresh Rajan' -I couldn't get response for this fql.
string s = fb.fql.query("select name, pic_square, profile_url from user where name = 'Suresh Rajan'");
if (String.IsNullOrEmpty(str1))
Response.Write("Empty Response");
else
Response.Write(str1 + " ");
how to search by name in facebook fql.
View 1 Replies
Mar 31, 2011
I have a simple page containing a GridView control that generates thead and tbody tags after rendering. In my jQuery script, I have a line that reads this way:
$('#GridView1
thead').eq(0).html()
When the page loads for the first time, this script returns an objects and works well. But when I click a button and cause a postback, it returns null. By the way, the button changes the number of the rows returned from the data source (based on the value of a textbox) and updates the grid.
View 1 Replies
Jul 1, 2010
I added a new table to my type dataset. When the code tries to execute the new row on that table I get the error message.
(if you can't see the error. "MissingMethodException was caught" "Method not found: 'MyTableDataTable MyNamespace.get_SSCase().")
I've tried the wizard and also click and drag the table from solution explorer to the xsd file. The other tables work, just this one table won't work. What should I check?
View 1 Replies
Nov 29, 2013
I have detailsview control with bound fields...some usingĀ Templatefields. I am trying to access values in those fields but i get nulls....i really dont know why..I am proving all my code....
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Projects.aspx.vb" Inherits="Projects" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Projects Statuses</title>
[code]....
I guess something might be getting messy with the mode changing event... a postback? But if i remove the databinding code, i get an error! why find control returns null??
View 1 Replies
Jan 26, 2011
I'm creating an LDAP class that contains a function that returns the managers username of the current user.
I know that I can use the "manager" attribute to return CN="name", OU="group", DC="company" etc.I specifically want the managers username, does anyone know if there is an attribute string that I can send to LDAP that specifically gets the managers username only? If not, is there an alternative method to do so?
View 2 Replies