|
Hello!
I have a nice book on ASP.NET but it doesn't explain how to for instance transfer data like a string from one aspx file to another.
What I want to do is enter a string in Default.aspx and then pass that string to Default2.aspx, so that the string can be used in Default2.aspx.cs
I tried a lot of things, but they were all guesses.
Could someone give me some pointers?
Ranger.
Novice
|
|
|
|
|
|
Default.aspx.cs
protected void Button_Click(object sender, EventArgs e)
{
Context.Items["SourceLabel"] = SourceLabel.Text;
Server.Transfer("Default2.aspx");
}
Default2.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
TargetLabel.Text = (string)Context.Items["SourceLabel"];
}
This should work, but it doesn't. Did I forget something?
Ranger.
Novice.
|
|
|
|
|
All I am trying to do is pass a string from Default.aspx to Default2.aspx,
and it just doesn't seem to work!!!
Ranger.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" ClassName="_Default" %>
public partial class _Default : System.Web.UI.Page
{
public string message
{
get
{
return BronLabel.Text;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button_Click(object sender, EventArgs e)
{
Server.Transfer("Default2.aspx");
}
In Default2.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ Reference Page="~/Default.aspx" %>
public partial class Default2 : System.Web.UI.Page
{
_Default sourceClass;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
sourceClass = (_Default)Context.Handler; <<< exception cannot cast
DoelLabel.Text = sourceClass.message;
}
}
}
Novice
|
|
|
|
|
At a glance you seem to be relying on server.transfer, which, when properly execute, will make the query string and any form variables from default available to default2.
try changing
Server.Transfer("Default2.aspx")
to
Server.Transfer("Default2.aspx", true);
Here is an article on this:
Server.Transfer Vs. Response.Redirect[^]
|
|
|
|
|
TopCoderJax wrote: Server.Transfer("Default2.aspx", true);
Tried it it didn't work and I didn't get the message associated with the bug.
Will read the article you posted, thanks!
I was thinking, could it be because the 'sender' is the Default.aspx that it won't work?
Will try some more tomorrow.
Thanks,
Ranger.
Novice
|
|
|
|
|
Tried it, and it works now!
Thanks!
Ranger.
Novice
|
|
|
|
|
i got an HTML form with the action="/scripts/myASP.asp"
but when submitting , the browser gets error that : couldnt fined "/scripts/myASP.asp"
what could the reason be !?
|
|
|
|
|
Did you create the file myASP.asp in the scripts folder.
|
|
|
|
|
Gday everyone,
I have a problem that I really need your help
I have a hyperlink, when users click on it, it takes to a lower part in same page.
Please help
Thanks
eric
|
|
|
|
|
|
Thanks enjoycrack,
I would not know how to do it.
Please guide me. I'm a newbie in ASP.Net
Thanks
eric
|
|
|
|
|
Just open the html of that page...you see:
Frequently Asked Questions this is named as 'FAQ' and here is the hyperlink Frequently Asked Questions ==> so when user clicks on this link, this will jump to FAQ section on the same page..
Hope this helps
<< >>
|
|
|
|
|
I got it.
Thanks so much
eric
|
|
|
|
|
uploading images
I am creating a form to store images in the database.
the user should enter the image title, comment then upload the image.
I want to store the image in the database as binary... I mean the column type is binary.
but I really don't know how to write the code that upload and stor in the database.
Can anyone help me please?
Thanks
|
|
|
|
|
|
thank you
|
|
|
|
|
hi ,
i want to use dropdown in grid view while binding it with the data table how can i do it in the optimize way
thanks
|
|
|
|
|
Is there any difference between creating a database from Templates((( choosing sql database)) and server explorer(((creating new sql server database)))??
|
|
|
|
|
What templates?
only two letters away from being an asset
|
|
|
|
|
IN ASP.NET 2.0 RIGHT CLICK ON PROJECT IN SOLUTION EXPLORER
--> CLICK ADD NEW ITEM --> TEMPLATES
|
|
|
|
|
If you can't be civil and not shout your response then stop posting here.
The difference is that from the server explorer you are creating the database on the specified SQL Server, from the New Item -> SQL Database option you are creating a mdf file, a local SQL Express database file. It is clearly identified as such by the item's description, "An empty SQL database for local data" and the default name for the item, "Database1.mdf"
only two letters away from being an asset
|
|
|
|
|
Hello Mark,
Can u please help??!!
I want to have file management in a portal.
((( create file, write in it, edite, delete and save in to database!!)))
I have searched but didnt find anything good related to this.
|
|
|
|
|
|
Are you getting any values? Did you view the source of the page to see what the html looks like?
Its a very simple example and I did not see anything wrong with it, Try adding a response.write("Testing") via vbscript just under the first body tag and comment out everything else on the form handler (process.asp).
|
|
|
|