C# - Sharing An Object Between Methods In Same Class (with Postback)?

Nov 19, 2010

I have a user control with a number of methods. I also have a dataset object that I'm filling in one method, but I also need to access that same dataset (and the data in it) in another.

I am filling the dataset from some xml that I get from a webservice when someone clicks on a button. The data from the dataset is then bound to a listbox control. When someone selects an item in the list control (I have autopostback set to true on it) it then fires off another method and it's this method where I need to access the data in the dataset, but when I check the immediate window it's telling me that the dataset is set to null.

Where am I going wrong?

[code]....

View 4 Replies


Similar Messages:

Security :: Not Extending MembershipProvider Class And Putting All This Methods In Some Unique Class And Call Its Methods Then?

Sep 16, 2010

I am beginner in web applications development. I started one little project and host it on source forge "https://homoco.svn.sourceforge.net/svnroot/homoco". And I started implementing authentication in this application to learn how it works. From my experience people never use out of the box things so I want to implement this stuff alone (like in real world projects). So some questions:

1) Is there any reason to use membership out of the box? To use database table schema, stored procedures etc. that tool generate for developer. I think that this lower control over code and I decided to implement it my self. I don't know if I am right.

2) Is my approach in this demo project good or bad (if someone have time I like to do just a little code review)? I created database based on business rules. Not using database schema that membership provider require. Extend "MembershipProvider" class to satisfy my needs. Implement queries to database myself.

3) Now, this question is a little wired but I have to ask it. If we make custom Membership Provider and do sql queries alone, implement all MembershipProvider class methods ourselves, and in application use Membership.blabla() why is this approach different from not extending MembershipProvider class and putting all this methods in some unique class and call its methods then? I hope that someone understand what I ask here.

I am sorry for three questions, but I really trying to find the best way to implement this feature in my demo project like it is a real world application.

View 3 Replies

Web Forms :: Class Object Becomes NULL After PostBack

Feb 13, 2014

I have a asp.net page titled EstMaterials.aspx with a gridview that fills from a SQL table based on a parameter passed to it.  The code for calling the form is below.

<asp:UpdatePanel ID="upAddMaterials" runat="server">
<ContentTemplate>
<div id="AddMaterials" style="text-align:center">
<asp:Button ID="btnDecoy" runat="server" Text="Decoy" style="display:none" />
<asp:LinkButton ID="lbAddMaterials" runat="server" Text="Add Materials"></asp:LinkButton>

[code]....

 I have an a button field set as a link in a gridview.  When the user clicks on the link it should open the "EstMaterials.aspx" page with a gridview listing the materials required for this job.  If I do not have a parameter i.e, ScheduleWeek.oJob.JobSeqNbr, the gridview fills fine.  However, with the parameter listed the gridview does not fill.  It appears the form opens without ever looking at the parameter being passed.The page load event is below.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
If Not IsNothing(ScheduleWeek.oJob) Then
Dim tbl As New DataTable

[code]....

View 1 Replies

Postback - Store Object Class In Viewstate (or Other Ideas)

Sep 8, 2010

I've build a class like this:

[code]....

The values of this class are set at postback by clicking a radiobutton list. Problem however is I don't know how to save this values across multiple postbacks. I thought of using viewstate but I'm not quite sure how to do it with this class.

Maybe I'm missing some important thing here.

Hope someone can point me in the right direction.

View 4 Replies

Sharing Single Database Connection Between Several Methods Simultaneously?

Feb 8, 2010

I have a page where a user can insert some order about some product. In that page there are also live statistics which is being refreshed every 20 seconds to reflect the current price of a product using asp.net timer. This live panel fetching these prices from a database.

When sometimes an order is being inserted, I get an exception saying that the connection is closed and the insert command cannot continue. I suspect that when the insert command is given, if at that exact moment the live update is being refreshed, then they both need to access the database, and they are using the same SqlConnection Object. So when one finishes, the connection object being closed even if the other one is using the same connection object.

Before closing a connection, how can I be sure that no other methods are using that connection?

The code of my connection class is given below, for better clarification -

[Code]....

View 4 Replies

State Management :: How To Persist A Class Object When Page PostBack

Oct 5, 2010

i have created a user control UserControl.ascx, in Code behind file of UserControl.ascx i have created an object of a class MyClass.cs,

Like

if(!Page.IsPostback) {
objMyClass= new MyClass();
}

but when i click on button of UserControl.ascx page and try to access objMyClass object then it set as null, so how to persist MyClass object when page PostBack, i wanted to keep object persist till the user access the page, when user goes out of this page then object should distroy?

[code].....

View 9 Replies

How To Define Properties And Methods Of Class That Inherit Stream Class

May 15, 2010

here is the code, where i am confused what to write in all the properties and functions of the base class stream?

I want to inherit abstract class Stream, but confused about what to write?

[Code]....

I could'nt understand how to define these Properties,Sub and Functions. How i start?

View 20 Replies

Web Forms :: Sharing Class Files Across Projects?

Oct 18, 2010

Using ASP.NET v3.5 / VS2008.

Is there a way to share class files across web site projects without actually making a physical copy of the file to the App_Code folder of each project?

View 9 Replies

Web Forms :: Sharing A Structure Or Class Among Multiple User Controls?

Feb 2, 2010

I'm building an application where custom modules may be developed and "dropped in" to the system, where they can be picked up and utilized.

I'm building a forum module and have a user control to create a login/registration region. I plan on using a struct to store the user session data. However, i need this class structure to be shared between the forum module and the login/registration control.

Because the functionality is to be contained in the module's folder, i cant add any assemblies to the app_code folder.

How can i share a class or struct among two user controls?

View 6 Replies

How To Call Methods On Object

Oct 17, 2011

I'm teaching myself web services at the moment and I've hit a bit of a stumbling block:-I've implemented a set of services for ordering shutters.These services use an underlying object model consisting of an order and a shutter class.The CreateOrder Service returns an order object and I now want to be able to add shutters to it by calling myOrder.Add(myShutter).

The problem is that the asp.net site I'm using to test it can't "see" the Add method on Order. If I browse the object tree I can see the Order Object but when I drill into it no methods are visible. Is this something to do with the way I've added th reference. edit> I just found the class in the "Reference.vb" file and aded this to it:-

Public Sub Add(ByVal Shutter As Shutter)
End Sub

Just about to test that. edit>I found this site and what he sugests fixes the problem but...I've had to add a local reference to the ObjectModel project to the web site. That seems wrong to me. It's not a web reference so how will this work in the real world. Once I actually deploy the service a project on a remote client isn't going to understand a local reference is it?

View 5 Replies

Security :: Role Class Methods Not Being Detected?

Feb 5, 2010

I'm trying to create roles for my web application using the Role class methods provided in ASP.net but when I attempt to use the class methods as such:

[Code]....

View 5 Replies

Web Forms :: Invoking Methods In The Base Class?

Mar 8, 2011

We have a base class that all our webpages in our application inherit from. I have a static method in the base class which when called will clear values from the application cache. Now the issue is this method needs to be triggered from a source outside the current application. I there any way this can be accomplished without creating an aspx page that will call this base method on page load.

View 1 Replies

Reflection Retrieve Private Methods Of A Class?

Sep 13, 2010

I want to retrieve private (implementation and other) methods of a class which implements an interface and also is derived from (inherits) a base class.

How can I achieve this using reflection? Is there anyother way to achieve this?

This is wat m tryin to do. I need to view these private methods and their contents, I don't want to invoke them.

Dim assembly As System.Reflection.Assembly
Dim assemblyName As String assemblyName = System.IO.Path.GetFullPath("xyz.dll")
assembly = System.Reflection.Assembly.LoadFile(assemblyName)
assembly.GetType("myClass").Getmethods(Bindings.NonPublic)
assembly.GetType("myClass").GetMethods(BindingFlags.NonPublic) isn't working

View 2 Replies

C# - How To Convert Json Object To Custom Class Object In Web Service

Aug 30, 2010

I've scenario where I want to insert data into database without post back. there are around 12 to 13 fields which i need to insert. I'm passing DTO from the client side which is actually Json object. Now the problem which i'm facing is how to convert that Json object which i got in webservice to the "class" (in my case class name is User) object.

[Code]....

In the above case AddNewUser method takes the object of User class. But i'm getting casting error. So how do I convert Json object to the "User" class object?

View 3 Replies

Create A Log Everytime When Methods In An Interface Class Are Called

Dec 30, 2010

I want to update a log file(txt) everytime when methods in a an interface class are called? Is there any way to do this other than writing code in every method to create log?

View 3 Replies

Visual Studio :: Class Methods And Code Behind Events Diagram?

Jun 23, 2010

is there any tools within VS2008 or Free 3rd Party tools where i can generate a Diagram of Class Methods and Code Behind events. think of the Table Diagram of SQL, it will show all fields, Primary Keys and to what table it is connected via foreign keys, etc.That is what i wish to make, in a much faster way, where it will show all class and within it is all the methods then linking them are the Code behinds and the event where the class is called.

View 3 Replies

To Add A Class To An Existing Class Attribute Of Object Via C#?

Jul 20, 2010

I have an existing class for an input, is it possible to add an additional class for the object in C#.net, instead of doing a if/else and not having a preset class on the object in the first place?

View 3 Replies

How To Use Facebook Sharing And Tweet Sharing Tools

Dec 1, 2010

I see on the bottom of blog pages a sharing buttons (Twitter and Facebook), where if clicked the link behind (which is normally the blog page url) the fshare button takes the clicker to the blog site facebook page respectively.

How does one do this in asp.net 2 , does one one use the <%# %> in the url part of these share buttons, are there any examples of how this is done?

View 8 Replies

Creating An Abstract Class That Will Define All Database Manipulation Methods To Implement

Mar 3, 2010

I am developing a couple of small ASP.NET application and would like to know what pattern. approach do you use in your projects.

My projects involve databases, using Data access and Business logic layers.

The data-access approach that I was using so far is the following(I read in some book and liked it):

For DAL layer:

Creating an abstract class that will define all database manipulation methods to implement.
The abstract class will contain a static "Instance" property, that will load (if instance == null) an instance (Activator.CreateInstance) of the needed type (a class that implements it).

Creating a classes that implement this abstract class, the implementation will be according to the databases (SQL, mySQL and etc) in use.

With this I can create different implementation according to database in use.

For BLL layer:

A class that encapsulates all all retrieved fields , and static methods that will call the DAL classes.

View 3 Replies

Assign A Hidden Field Value On Default.aspx Using BasePage Class Methods?

Nov 3, 2010

Is that possible? The reason why am doing this is because I need to parse that variable into a an JQuery function so I wanted JQuery to read that field. Can I Assign that value in base class or I have to do it within default.aspx pageload method?

View 1 Replies

Delegates Represent Methods That Are Callable Without Knowledge Of The Target Object

Dec 15, 2010

Can somebody justify this statement with example: delegates represent methods that are callable without knowledge of the target object. i am not getting how we are hiding the function name at the UI.

View 4 Replies

Alternative For Static Method In Interface - Enforce Implementing Class-level Methods

Oct 28, 2010

I have a hierarchy in my website project as below:

[CustomControl1 - folder]
- CustomControl1.ascx
- CustomControl1.css
- CustomControl1.js

I load css and js files dynamicaly based on which controls are used on particular page. I am doing it by using following code:

[code]....

where AddLinks method adds HtmlLink controls to Page.Header with href attribute set to coresponding css and/or js file.

I would like to add Interface that would force new controls to have AddLinks method but it is impossible since it is a static method. Because my custom controls inherit from Control class I cannot use abstract class and/or virtual methods either. How can I achieve my goal?

View 1 Replies

AJAX :: How To Avoid Cascading Dropdowns To Call Their Service Methods On Every Postback Of The Page

Feb 24, 2011

I have three cascading dropdowns on my web page and they work fine. The issue I am facing is that there are other controls on the page which cause a postback and with each postback the cascading drop downs are being re-populated (service methods are called) which is becoming a performnace issue.

View 1 Replies

What Is Name Of Class To Make An Object Of Div Class

Jan 30, 2011

Actually i want to cast the type from find control to div but i cant find the class with div or body or form name why so?

View 5 Replies

AJAX :: MSAJAX BUG: Overrides Of ToString () And Other Methods Present In Object Do Not Propagate To Derived Classes?

Oct 8, 2010

MSAJAX: overrides of toString() and other Object methods do not propagate to derived classes

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved