C# - Accessing Page Controls From A Separate Class?

Aug 6, 2010

I'm wondering how I can go about accessing page controls from a separate class I've made. I've tried a few things I found using google, but no luck :(

What I'm trying to do is keep a function that is used often, in a global class.

The function then accesses a page literal and calls ScriptManager.RegisterStartupScript. I was hoping this is possible, so then this function wouldn't have to be copied to all of the pages.

View 4 Replies


Similar Messages:

Web Forms :: Accessing Page Controls From Class

May 17, 2010

I need to be able to access simple page controls like a textbox from my page class. So if I have a simple aspx page with a textbox on it, I'm trying to do something like this. i'm not using codebehind btw:

[Code]....

I thought maybe I could pass a reference to the page into the class, something like:

[Code]....

But that's not working either. How can I access page controls from my class?

View 5 Replies

Accessing Controls From Separate Classes

Jun 23, 2010

I have an ASP.NET Web Site I am creating in Visual Web Developer 2008 Express using Visual Basic as the language. It is actually a rewrite-with-mods of an existing ASP script and I'm trying to chew what I've bitten off. I created my page with a text box (txtOutput) on it and since the end product is very complex, and it's generally good practice to separate like functions, I have created 4 separate classes in the App_Code section.

My main page is Sync.aspx and has a code file Sync.aspx.vb with it.

One of my code files is SyncDatabases.vb and in it I have created

Public Class SyncDB

In that class I have created some routines such as

Public Function ReadMSDB(ByVal SQLString as string) as Boolean

In this routine I want to put information in my text box txtOutput on the main form (the default - Form1).

My problem is that if I try:

Form1.txtOutput.Text = "Hello world"

or just

txtOutput.Text = "Hello world"

it says Name 'Form1' (or 'txtOutput') is not declared. I am sure I am missing something simple but have no clue what it is. I assume it's the fact that the write command is in a file (class?) outside the file (class?) containing the page itself but I don't know how to address it properly.

View 4 Replies

How To Reference A Field In Another Class In A Separate Aspx Page, Using C#

Aug 19, 2010

I have a 2D array of doubles in my Default class on my Default.aspx.cs page, like so:

protected Double[,] time;

By the time the page loads, I have populated this array from a database. Now, I want to reference this array in another file (Diff.aspx.cs) to avoid visiting the database again. Also, the data is used in a read-only fashion.

View 2 Replies

Forms Data Controls :: Create A Gridview In A Separate Class?

Feb 9, 2011

Does anyone know if it is possible to create a gridview from a class on a seperate webpage?

So I have webpage 1, that calls Class 1, in Class one there will be a Select Query that will call some info from a database and then return it to a gridview. The gridview wont work obviously as it is in the class and not on webpage 1.

Is there anyway to reference the fact I would like the gridview created on webpage1?

View 1 Replies

Web Forms :: Accessing Master Page Control From Class File?

Aug 27, 2010

i have to write this piece of code in almost 10 to 15 content pages. i am just wondering if i can class file as base class for my content pages and write this piece of code in that class.

[Code]....

can somebody guide me how to write the base class for this scenario?

View 6 Replies

Web Forms :: Accessing HttpResponse Page.Response From A Class Instead Of Cs File?

Oct 18, 2010

I have an issue with trying to create a Pdf file from my webpage. Basically, everythig involving creating the Pdf (using iTextSharp) is done, and I'm doing this as a File Stream (i.e, I'm saving the Pdf on local machine). Now what I'm trying to do is create it as a Memory Stream (i.e, open the Pdf from the browser). I was able to do this earlier when I wa still at the 1st version of the application, and all of the code behind was incluced in my .aspx.cs file. But now, I've kept the code in the .aspx.cs at a minimum and put the cude in classes and I'm creating onjects of thoses classes from the .aspx.cs

The problem is that the code from creating the Memory Stream is in a class as follows:

[Code]....

As you can imagine, the compiler cannot recognise "Response" as it's in a seperate class instead of in .aspx.cs

View 5 Replies

C# - Accessing The Cache From A Separate Thread?

Mar 13, 2010

Normally i have a static class that reads and writes to HttpContext.Current.Cache

However since adding threading to my project, the threads all get null reference exceptions when trying to retrieve this object.

Is there any other way i can access it, workarounds or another cache i can use?

View 2 Replies

Web Forms :: Accessing Server Controls From A Class?

Mar 27, 2010

I have several .aspx pages that all have identical code behind pages.For ease of maintenance,I would like all the aspx pages to share a common code behind page.
To do this I have created a MyCommonClass class,which contains the common code.In the code behind of the .aspx pages, I have:

Partial class MyPage
Inherits MyCommonClass
End Class

But now the controls declared in the .aspx pages are not accessible in MyCommonClass.fix this?

View 6 Replies

How To Create A Log File As A Separate Class

May 13, 2010

I'm web dev newbie. I'm trying to create a log file as a separate class that will catch every exception , the thing is I don't much about files, where it is created, the path should be given or not, where is the ideal place to create it

View 3 Replies

DataSource Controls :: Display Results From Two Separate Tables In Two Separate Databases?

Jan 14, 2010

I have access to two seperate databases (mySQL) located on two servers. I need to get the data, link the tables on a key field and display the results in a datagrid. My challenge is that if the search criteria changes for the display it affects rows returned from on table and should thus automatically affect the linked table and resulting data returned.

what the best approach would be to achieving this? So far I have set up a dataset with a dataadapter and table for each connection and then linked the tables in the dataset. The problem that I'm having is getting the linked resultsets to work.

On my form I have the datagrid with two Objectdatasources one for each dataadapter and i believe that's where I'm going wrong...

View 1 Replies

Forms Data Controls :: Accessing Properties Of The GridViewRowEventArgs Class Within A Regular Method?

Jan 6, 2010

I have a regular method I want to call. I need to use properties of the GridViewRowEventArgs Class within this method.

i.e.

[Code]....

Of course the above code is not valid because I don't think you can put GridViewRowEventArgs within the method like that. I don't want to put it within a event handler because that even handler is doing other things. I want to be able to call this seperatley.

View 2 Replies

Forms Data Controls :: Open A Page In Separate Browser When Imagebutton Click From Parent Page?

Sep 29, 2010

In parent page there is an imagebutton. What I want to when user click this image button, another page will open with width=200 and height=100 with no toolbar.

View 11 Replies

C# - Adding And Maintaining Named Strings In A Separate Class File?

Aug 3, 2010

I have developed an asp.net web application containing 40-50 pages. I have implemented logger using Log4net and each of my pages has this in its page_load event.

[code]...

This method has many strings like "In page Load function","OrgId","Homepage.aspx?Sid=1","Page load function successfull". Now i would like to maintain these string which are common throughout my application in a seperate class file and use it with a variable...

View 2 Replies

How To Make A Class Recognize That An Interface Found In A Separate File Exists

Mar 8, 2010

I've made an interface called ApprovalEvent in a separate file with the namespace myproject... I've also made a class called PurchaseOrder... it's also in the same namespace, just in a separate file. Whenever I try to make PurchaseOrder implement ApprovalEvent it always says that ApprovalEvent is undefined...

How can I make the class recognize that the interface exists but is in a different file?

Here's some code:

[Code]....

View 1 Replies

Data Controls :: Print Each GridView Row On Separate Page

Jan 15, 2014

in my webform --

when user input the valid data then there will be generate a areport and that report displays in a gridview itemtemplate. when i print the report, only first page data printed properly on a predesigned designed paper. and others are not. then how to print each rowdata of gridview on per page.

View 1 Replies

Forms Data Controls :: Populating GridView On Separate Page?

Dec 10, 2010

I'm generating a number of calculated arrays in the code behind a ButtonClick event on a particular page. Stuff like:

Dim Delta(,) As Double = New Double(nPer - 1, 0) {}
For i = 0 To nPer - 1
Delta(i, 0) = Delta_Buckets(i, 0) + fwds(i, 0)
Next

What I want to do is convert this to a datatable and use this as a datasource for a gridview in a different page.

View 2 Replies

Controls :: Export Repeater Item (Row) On Separate Page In PDF Using ITextSharp

May 7, 2015

I want to convert a repated contents of a repeater (binded from databse )to pdf using iTextSharp so that every repeated contents comes in new pdf page.. two or multiple unique records should come individually in new pdf page.

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Registrations.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();

[Code] .....

View 1 Replies

Forms Data Controls :: How To Display The Each Row In A Separate Page In Grid View

Mar 29, 2010

i have a need to display the each row in a separate page,

example: if a Grid view contains the 10 rows,each row should be displayed in one page(only that row only),when ever second row comes, first row should be removed from grid and second row should be displayed as a whole in that, like wise..when ever 3rd row comes 2nd should be erased and 3rd will come into Grid view.

i am using following code but not getting result as i want,

foreach (GridViewRow gr in GridView1.Rows)

View 5 Replies

Web Forms :: Master Page Controls Accessing Controls Inside Content Page And Vice Versa

Jan 26, 2011

i have a masterpage and has some linkbuttons in it, i also have a webform which is a content page for the masterpage. i like to access the controls to the webform via the linkbutton residing in the masterpage or access the linkbuttons via the webform controls.

View 1 Replies

Accessing A Class File In VB Or C#?

Nov 24, 2010

I want to access the functions defined in ADO.vb file in my Default.aspx.vb file. note that the ADO.vb file is in the root directory. I can access it if it is in the App_Code directory. It it is in the root directory how can i access that?

View 9 Replies

Forms Data Controls :: Accessing Master Page Controls From Content Page Formview?

Sep 22, 2010

I have a master page with a textbox that I want to use for a search, and display the results on the content page.

I've dragged in the datasource to the content page, and configured the formview to use that datasource... almost.

The issue I'm having is that on the last step of the configure datasource wizard where you select the parameters, I want to select the master page textbox control for the search parameter... but of course it's not available in the list. The list only allows me to choose controls from the content page.

How do I set this master page search box as the parameter for my datasource?

View 4 Replies

MVC :: Accessing An Existing Static Class?

Mar 15, 2011

So i have some existing functionality from an older ASP.Net app that is a static class.

Say there's a static method in that class that returns a dataset that I would like to bind to something like a gridview or whatever I can build using MVC3.

View 2 Replies

Accessing A Class Properties In Function?

Apr 15, 2010

I am unsure of how to reference the properties of my class in a function. Here is how I see it in my head, but how do i go about this?

WebService.vb

[Code]....

UserClasses.vb

[Code]....

View 4 Replies

Web Forms :: Accessing Previous Page Controls On Current Page?

Feb 23, 2010

I want to access controls (textbox and HTML hidden fields) from current page to do some transactions in my database.

View 3 Replies







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