|
I have 2 asp.net files: default.aspx.cs and test.aspx.cs
How can I call methods from test.aspx.cs from default.aspx.cs?
I can't seem to call methods from a different file unless it's in my appcode folder.
/\ |_ E X E GG
|
|
|
|
|
i think function calling is posible if class is placed in appcode folder.
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
Try this code
Use this line where u want to call Function
In .aspx page
<%@ PreviousPageType VirtualPath="~/index.aspx" %>
in .aspx.cs
this.PreviousPage.Login();
//Make sure your method is public
Best Regard
Pathan
-- modified at 0:54 Wednesday 1st August, 2007
---------------------------------------------------
|
|
|
|
|
imran i tried ur code
i got the following exceptions
Object reference not set to an instance of an object.
at the following line
this.PreviousPage.Login();
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
Now try this
take two page test1.aspx and test2.aspx
Take LinkButton in test1.aspx
<asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl="~/test2.aspx">LinkButton</asp:LinkButton>
and write public method
i.e
public string Login()
{
return "Welcome";
}
Now In test2.aspx
<%@ PreviousPageType VirtualPath="~/test1.aspx" %>
Call Method in page load event
Response.Write(this.PreviousPage.Login());
Run test1.aspx and click on LinkButton
Best Regard
Pathan
---------------------------------------------------
|
|
|
|
|
imran, have u tested the code u r providing.
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
Yes
---------------------------------------------------
|
|
|
|
|
well i have tested this code it really works great
|
|
|
|
|
The appcode folder is global to the whole application, then I loose isolation between debug and release code in my app.
/\ |_ E X E GG
|
|
|
|
|
Someone else was asking this the other day. You can't. You just can't. test.aspx.cs does NOT exist when default.aspx.cs is running. The class instances are created as the pages are served. If you have stuff you want to be able to call from many pages, give them a common base class.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Ok, then that clears it up. So I guess my next solution would be to put the common code I need, into an app_code folder.
/\ |_ E X E GG
|
|
|
|
|
Hi, if I don't want to use a DataGrid and don't want to use Stored Procedures for Paging purposes, what other options do I have? Would you please point me to tutorials on them if they exist, thank you in advance for your help.
|
|
|
|
|
Hi,
Usually I use Stored Procedure for paging. If U want paging without datagrid is okay, but if U dont want to use stored procedure then U should create a class for paging. It means for easy maintenance.
Regard,
Edwin
|
|
|
|
|
ASPnoob wrote: don't want to use Stored Procedures for Paging purposes
What is the role of stored procedure in paging. If know to implement manual paging with help of stored procedures, copy the same query to your page and append to string variable and pass to DB.
Do you have any specific reason for avoiding stored procedure ?
|
|
|
|
|
Hi,
I have a regular select statement, but it doesn't shows any data, may be I don't see sth, could anybody help me?
Here is the code:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:PapersDBConnectionString %>"
SelectCommand = "SELECT name, lastname, organization, addressline1, addressline2, city, state, country, zipcode, phone, newuser, moderator, date FROM Users WHERE (username = @current_user)">
<SelectParameters>
<asp:SessionParameter Name="current_user" SessionField="CURRENT_USER" />
</SelectParameters>
</asp:SqlDataSource>
thanx
|
|
|
|
|
I used following code and i get result
u can try it
<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:RelationshipPortalConnectionString %>"
="" selectcommand="SELECT * FROM [User_Registration] WHERE ([UserName] = @UserName)">
<selectparameters>
<asp:sessionparameter name="UserName" sessionfield="UserName" type="String">
-- modified at 6:47 Wednesday 1st August, 2007
Nand Kumar das
|
|
|
|
|
Hi,
My Provider is System.Data.OracleClient. I need to use the OracleTransaction with Enterprise Library Data Access Application Blocks. With out DAAB we can write Like this:
OracleConnection con=”…”
OracleTransaction tr=Con.BeginTransaction(..);
With DAAB we have to write like this:
Database db=DatabaseFactory.createdatabase();
OreacleTransaction tr=?
Here How to initialize the Transaction.
Can any one provide me the link to how to execute Oracle Transactions with DAAB
Thanks
|
|
|
|
|
Have a look at this link[^], if you look at one of his replies (almost towards the end), he shows how to use DAAB with transactions.
Tarakeshwar Reddy
MCP, CCIE Q(R&S)
There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group; there is less competition there. - Indira Gandhi
|
|
|
|
|
Hi, suppose I connect to a database to retrieve binary data from a field called Resume and retrieve the mime type from the DocTypes field (DocTypes field stores "application/doc, image/img, etc.). I then use a data reader to read the data and then use the Response.ContentType=DirectCast(Read"DocType",String) to set its mime type. WhatI would like to know is, if the select statement used to retrieve the data retrieves more than one file, which DocType will be used in Response.ContentType=DirectCast(Read"DocType",String) . Also if I decide to display the data using Response.Write(), whic file will be diplayed? I hope I'm making sense, thank you in advance for your help.
-- modified at 17:55 Tuesday 31st July, 2007
|
|
|
|
|
A datareader will return a set of rows, the order of which is determined by your sql query. If you are simply reading the first one then that is what will be displayed; otherwise you could loop through them and pick out whichever one you wanted (perhaps determined by an id passed in the querystring, though in that case you'd just return the one row to begin with. Really, for your scenario, you do only want to return the one row you want to display, and ought to try and make sure your datareader does only fetch that one row.)
|
|
|
|
|
Hi, thanks for your response. Up 'til now I've been using a dataset and filling it using the data adapter Fill() method, but haven't used data reads that much. You said the order in which the rows are returned is determined by my SQL query, do you mean using the key word DESC or ASC? Also how do I loop through and pick what I want? Do I first put the retrieved data somewhere like a dataset then loop throught it? Please explain, thanks again for your help.
-- modified at 18:40 Tuesday 31st July, 2007
|
|
|
|
|
ASPnoob wrote: do you mean using the key word DESC or ASC?
well, yes, amongst other things - basically the ORDER BY clause of your query
Dim objReader as SqlDataReader
Dim objCmd as New SqlCommand
...
objCmd.CommandText = "SELECT ... FROM ... WHERE ... ORDER BY..."
objReader = objCmd.ExecuteReader
If objReader.HasRows Then
Do While objReader.Read
' do stuff / test for condition
Loop
End If
objReader.Close
But really, I would have thought you would have determined the record you want to display already, probably on a previous page, and are calling this page with the ID (perhaps) of that one record, so you can retrieve it and set the page Response.ContentType accordingly - in which case you don't need to Do...Loop at all - just SELECT that one record in your SQL query
objCmd.CommandText = "SELECT ... WHERE ID = " & request("id")
objReader = objCmd.ExecuteReader
objReader.Read
...
Good luck - if you need more try looking up the 4guysfromrolla site - loads of examples - - I'mm off to bed!
Fred
|
|
|
|
|
Hi !
Thank you for reading this. Here is my problem. Iam creating a domain cookie so, other sites in my app can read values. How can i delete the cookie from the other site??? For example.. lets say my main site is www.abc.com, when user logs in, i create a domain level cookie like this
Dim cookie1 As HttpCookie = New HttpCookie("Cookie",1234567)
cookie1.Domain = ".abc.com"
cookie1.expires=datetime.now.addminutes(30d)
Response.Cookies.Add(cookie1)
this creates my domain cookie. my other site(lets say test.abc.com) reads this cookie...now i want to delete the domain cookie from test.abc.com. How do i do it? All help and code example are much appreciated.
Thanks
RH
|
|
|
|
|
set its "expires" property to a date in the past.
If you want to do this across domains though, you may find that the user has set their browser security settings to prohibit you from doing this. Nothing you can do about that.
|
|
|
|
|
Hi
When u r entering to other site, u first check for that cookie and remove it.
I have not failed. I've just found 10,000 ways that won't work. -Thomas A. Edison
Thank u
Chandu
|
|
|
|