how can i send parameter with writing code

M

miladhatam

hi
i am milad and i have started learning asp.net c# for 2 months
how can i send parameter to a page with code
i did this work with html by writing the destination address in action
thanks
 
P

paulcroll

Put the object / variable / struct etc into a session variable. This
is an object maintained in the background across all pages. You must
cast it back when retrieving it.
example showing what to to if putting a string into session variable.


putting into:
string s = "hello";
Session["mySession"] = s;


extracting:
string retrieved_s = (string) Session["mySession"];


if a cast doesnt work to convert it back, you may need to try the
Convert.ToString() method or whichever as appropriate for type
 
M

miladhatam

hi
thanks my dear friend
i am going to test your code
i am amateur in this case :)
my work field is in flash
i can do every work you want
thanks alot
 
M

miladhatam

i tested your code
this syntax didn't work in asp.net 2 with c# language
i think it works in asp
should i type any namespace ?
ofcourse i want to create a page for login to a another page
in first page username and password are checked if were correct go to
second page
but i don't want to a user type the name of second page and view the
page
i want to send a form parameter from first page to second page that
only let to view page if
that variable be true
i hope you understand :)
i amnot american and i can't speak and type in american well
thanks
 
P

paulcroll

dont worry, Im not American either. English.

Ok, so you want to send a boolean accross several pages.

so:

//on login_page.aspx
bool successfulloging = false;

//then write whatever code to test login details and set this boolean
appropriately.
//then put into session variable

Session[s_successfullogin] = successfullogin;



//on the other page you need to take the boolean out of the session
variable

boolean successfullogin = (bool) Session["s_successfullogin"];

if(successfullogin != true)
{
Response.Redirect("login_page.aspx");
}


you can use forms authentication in .net 2.0 also. This is very
simple.
 
M

miladhatam

thanks
i understand your help
thanks alot
can i request you that give me a link of an e-book about asp.net
c-sharp
or asp.net vb
only my english friend
what can i do for you about this good helps
thanks
 
P

paulcroll

hey,

Dont worry bout it, glad to be able to help. Unfortunately, I do not
use ebooks in this case. At work we have several c# books and the wrox
asp.net 2.0 books. Sorry cant help here.

good Luck.

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top