Web Forms :: Altering Object Values Across Different Classes?
Oct 17, 2010
I have two different classes, and would like to (for example) alter the text of a label control contained in one class using the other. At present I experience the following error (e.g.):
"ProjectName.PageName.Protected WithEvents ControlName As System.Web.UI.HtmlControls.HtmlGenericControl' is not accessible in this context because it is 'Protected'."
All the subroutines in my PageName class begin "Protected Sub...", however even if I change these to "Public Sub..." this does not fix the problem. How do I achieve this? Also, are there security implications to not protecting subroutines?
View 2 Replies
Similar Messages:
Jun 1, 2010
I am learning how to work with BLL and DAL
I have 2 class files in BLL and using DAL i am connecting to the sql database
in BLL i have a class called productsHelper.cs and using GetProducts() method used to fetch records from database
products.cs - have all insert,edit,delete methods
I want to bind all products to gridview
But I couldnt find how to do that.how to get those methods to my aspx.cs page from class files.and write code in there.
View 5 Replies
Jul 29, 2010
I have a website, and if there is an anonymous user (not logged in) then I want my navigation (a section of the master page) to show an element of the menu called "Login". But if there is an authenticated user then I want the navigation to NOT show this "Login" option, but to display a menu item/link to a resource that is only available to logged on users.I know how to set restrictions on files and webpages, but how do I implement this with the navigation menu?
View 16 Replies
Sep 6, 2010
I usually use STATIC implementation when developing Desktop Application and I just got my head bumped on the wall when I use STATIC in ASP.NET (not a good idea)I think I saw some feedback here before that you can use INTERFACE for passing values between Classes and Pages without using Session.here's my sample code
public interface ISessionManager
{
SessionStates sesState { get; set; }[code]....
View 2 Replies
Aug 24, 2010
I'm looking to print a file which is constantly being read too. Although, there are certain times when a user must print from this file. How do I print from this file and also alter the font depending on which item I'm printing. For instance, we have 3 items in a text file.
76277BLACK WHITE 001.300601R W2308101/4
76287BLACK SCANDA000.500208 E W2308101/4
76289BLACK WHITE 006.801701 W2308101/4
Two of these items need to be printed in a bolded font. The one with the 'R' and the one with the 'E'. I want it so that I f I were to print this particular job off with these three items. I would have two lines which would be bolded and the third line would be regular font. It would look something like this
76277BLACK WHITE 001.300601R W2308101/4
EXPORT
76287BLACK SCANDA000.500208 E W2308101/4
76289BLACK WHITE 006.801701 W2308101/4
If you look above I also need to denote that if an R is present it is a remake, if a E is present, it is an export.
View 1 Replies
Oct 8, 2010
MSAJAX: overrides of toString() and other Object methods do not propagate to derived classes
View 1 Replies
Mar 24, 2010
Can I use VB and C# classes together in the same asp.net 3.5 project?
View 3 Replies
Jan 8, 2011
Prior to using a ViewModel, I could easily pass the "soon to be edited" object directly to the view without needing to fuss over setting individual properties etc as the View conveniently accepted the Employee type directly..
[HttpGet]
public ActionResult EditEmployee(int? id)
{
EmployeeRepository ER = new EmployeeRepository();
Employee SomeEmployee = ER.GetEmployee(id.Value);
if(SomeEmployee!=null)
return View(SomeEmployee);
But now I'm using a ViewModel with DataAnnotations attributes applied over the top of various properties for validation purposes. Which creates a problem.. After fetching the "soon to be edited" object from the db, setting the ViewModel's values is suddenly a whole lot more complicated. I can't simply pass the retrieved object straight to the view, as the View now expects the VMEmployee type instead. I would like to be able to do something like:
[HttpGet]
public ActionResult EditEmployee(int? id)
{
EmployeeRepository ER = new EmployeeRepository();
Employee SomeEmployee = ER.GetEmployee(id.Value);
if(SomeEmployee!=null)
return View(new VMEmployee(SomeEmployee));
All paths seem to lead to a huge constructor which manually sets the values of each individual property. But I never had to do that before when I wasn't using a ViewModel. Model binding was a blessing! My objects also have complex child objects, which my form is also collecting values for, so this would be a huge/verbose task against DRY principals. I don't even really want to use a ViewModel, but am forced to because I need two different DataAnnotations rule sets for different validation scenarios applied to the same object.
All I want to do is be able to have two different DataAnnotations rule sets for different scenarios. I.e. public-facing www site vs internal-facing admin site. DataAnnotations doesn't seem to be flexible enough to easily cater for this common need. I've tried AutoMapper, but it throws an error saying it can't map my object types, I suspect because Employee was auto-generated by LINQ to SQL. What is the most elegant way to achieve this while sticking to DRY principals?
View 1 Replies
May 2, 2010
I want to do some processing on a attribute before returning the view. If I set the appModel.Markup returned in the HttpPost ActionResult method below to "modified" it still says "original" on the form. Why cant I modify my attribute in a HttpGet ActionResult method?
[HttpGet]
public ActionResult Index()
{
return View(new MyModel
{
Markup = "original"
});
}
[HttpPost]
public ActionResult Index(MyModel appModel)
{
return View(new MyModel
{
Markup = "modified"
});
}
View 1 Replies
Jun 30, 2010
I know its a pretty simple one but since I am new to asp.net I need your help on this ,can anyone please give me the code in VB for the below code, I want to alter my table "Upload" and the name of my connection string is "ASPNETDBconnectionString1"
using (DbConnection connection = new SqlConnection("Your connection string")) {
connection.Open()
using (DbCommand command = new SqlCommand("alter table [Product] add [ProductId] int default 0 NOT NULL")) {
[code]...
View 4 Replies
Jan 11, 2010
I am new to LINQ. when we drag tables we get a dbml file and designer file.
For example DataClasses1.dbml and DataClasses1.designer.cs.
Once we have them then we can start using our LINQ Queries.
In my company project I do not see this designer files and instead there are .tt files which were used as templates to greate ABC.generated.cs files. Is this same as designer class?
View 3 Replies
Mar 10, 2011
i have problem white Object datasource. i have a multi-tier Application that include common layer ,DAL Layer,business logic and persantation layerwhen i add a object datasource to my page, it bring me only common layer classes . but i want use bisuiness layer classes what do i do ?
View 1 Replies
Jun 16, 2010
We have a service that generates a report (using word templates and a 3rd party library), and then returns a string in HTML. While this HTML isn't great - its formatted correctly in this string. We want this HTML to show up on a page - format intact. What we currently have done is set an ASP.net Literal's text element to this string. While this works, I have noticed that it has reformatted the HTML string slightly. For the most part, it looks like it generated a bunch of new CSS classes, and a new style element in the HTML. This HTML does not exist in the string thats being returned. I could filter all of this back out, but wonder if there is a better way. I assume that the Page itself is altering something. What is the best way to display this raw HTML back to the user? I can't directly use a Response.Write(string), because this page does have a few other controls on it.
View 3 Replies
May 17, 2010
I am following the Nerd Dinner tutorial as I'm learning ASP.NET MVC, and I am currently on Step 3: Building the Model. One part of this section discusses how to integrate validation and business rule logic with the model classes. All this makes perfect sense. However, in the case of this source code, the author only validates one class: Dinner.
What I am wondering is, say I have multiple classes that need validation (Dinner, Guest, etc). It doesn't seem smart to me to repeatedly write these two methods in the partial class:
[code]....
This doesn't "feel" right, but I wanted to check with SO to get opinions of individuals smarter than me on this. I also tested it out, and it seems that the partial keyword on the OnValidate method is causing problems (understandably so). This doesn't seem possible to fix (but I could very well be wrong).
View 1 Replies
Aug 11, 2010
I don't know if this has to do with how FindControl works or how scope works. But my base class is having a hard time seeing the fields of child classes. Currently I'm planning have the derived class set a property in the base class, but there are a lot of derived classes, so that isn't a very attractive solution.
[code]....
View 4 Replies
Sep 25, 2010
I wanTransfer values from one page to another using Request Object
but when i try store
textBox value into Request object like..
Request["Name"] = txtName.Text;
i get the following Error
Property or indexer 'System.Web.HttpRequest.this[string]' cannot be assigned to -- it is read only
Is Request object allows us to store values init like Session & Application Object.
View 11 Replies
Dec 15, 2010
I'm curious as to what people consider better practice, between duplicating model structure in the view model and using a mapping tool to move data between the two, or aggregate the model inside the view model, i.e. have a property on the view model class that is a reference to the actual model. Which is considered a better approach in general?
View 1 Replies
Mar 9, 2010
I am trying to update record in gridview using ObjectDataSource (with conflict detection)The following is the ObjectDataSource
[Code]....
Update Method is as follows
[Code]....
In ObjectDataSourceProducts_Updating(..) event , I am checking objects which are being sent to UpdateProduct(..) method. I found that both the objects " original_ProductDB and productDB " have the same the values. When I click "Update" in GridView after entering new value, ObjectDataSource is not picking new value
[Code]....
GridView is as follows.
[Code]....
ProductBO is as follows
[Code]....
View 3 Replies
Jan 31, 2011
i m having a bit of trouble here with .. i am changing the text from a dropdown inside the gridview to a cell inside that perticular row.... the code for the jquery i hav used to alter the text is :
[Code]....
the corresponding gridview is :
[Code]....
now after the text is changed into the corresponding cell ... i m trying to access it as per normal server side code as :
[Code]....
View 5 Replies
Mar 8, 2010
Except session and viewstate or a control with a value (including sqldatasource).Is there a way to store the value(s) in an object that will not loose the value if the page refresh?And also the best practice to hold sensitive value? I'm using viewstate with encryption for now but if p.e., have to hold a dataset then the page size will rise dramatically.
View 23 Replies
Mar 29, 2011
I want to get an object typed properties values. Here is my code:
Type tip = Type.GetType(pair.Key.GetType().ToString());
object uretilenNesne = Activator.CreateInstance(tip);
uretilenNesne has correct type but I want to access uretilenNesne's properties values.
View 1 Replies
Feb 5, 2010
I am using logger to record all error information.
When log error informtion we need to
logger.error("User.UserID" & user.userID)
logger.error("User.pw" & user.pw)
And what I am trying to achieve is;
logger.error(myClass.getObjectInfo(user))
and I want myClass.getObjectInfo can list all of the object property along with values.
View 5 Replies
Mar 25, 2011
I have the following result in my controller from the $.toJSON method;
"[{"param":"Update Payment","value":"50.00"}]"
How do I extract the values from param: and value: ???
View 4 Replies
Jan 12, 2011
I have created two objects and placed id ViewData , I dont Know how to retrieve values of each object in the view..
var t = new List<Table1>()
{
new Table1 {Id = 123400,Name="Kalees00"},
new Table1 {Id = 12340011,Name="Kalees0011"}
};
ViewData["ListValues"] = t;
return View(t);
View 6 Replies
Jan 28, 2011
I'm working on an application that uses an approach to localization where they just call a translate function for every piece of text on a page. It leads to a lot of redundant code that looks like this (psuedocode):
function page_load():
translateControlText(control1, language);
translateControlText(control2, language);
translateControlText(control3, language);
translateControlText(control4, language);
translateControlText(control5, language);
translateControlText(control6, language);
translateImageAlt(image1, language);
100 more lines of this on a single page
The application is massive, so I don't have the opportunity to rewrite the translation logic. However, I think I could just loop through all of the controls on a page, check their type, and translate the appropriate property. At least then I would just have to call 1 function per page, and then throw it in a base page or master. However, I probably wouldn't want to translate certain things, such as table cells. Regardless, there is an attribute called Localizable that is on many properties such as Control.Text and Image.Alt. I'd like to be able to get a list of every string on the Page that is stored in a Property marked Localizable. Is this possible? Is this possible without reflection?
View 2 Replies