|
Hai,
Its surprising me, that no one discusses about the traditional . It didnt work. Because the submit button always tries to call the Page_Load function of the same page.
Surprising enough, none of Microsoft's documentation discusses about the action attribute. Wondering whether it is not required since the form itself is running on the server.
Then how would I jump to a different page?
omkamal
|
|
|
|
|
Doesn't Response.Redirect() work anymore?
|
|
|
|
|
But why do I want to use Redirect? Why not posting form values to a different page by calling that page? Like what we used to do in ASP.
omkamal
|
|
|
|
|
In ASP it was a different story: you had one page with HTML form and one page with ASP code to process the data. Now you can do it all in one page without creating a mess out of your code and without having all those extra pages. That is one of the good things about ASP.NET, as far as I concern...
|
|
|
|
|
Lets say I have a login form. It takes username and password and based on this authentication I would have to display (possibly in another page) an xml data in a datagrid. Now how would I do this all in one page. I cannot play hide-seek with my controls in the page. I would rather have it in a different page. Am I right?
omkamal
|
|
|
|
|
Before:
login form submitted to page2.asp
page2.asp checks credentials
if credentials not valid you send them back to login.asp
if valid you return XML.
Now:
login.asp submits to itself
you check credentials on page_load or button_clicked
if credentials not valid you do nothing
if valid you send them to page2.asp via Redirect.
All the code that relates to logging in is now in one place and not spread across multiple pages. All the code that concerns displaying of the XML is in the separate page. Much cleaner solution IMO.
|
|
|
|
|
Sounds great though. But my surprise is, what if I wanted login info in my page2.aspx? What is the use of HttpRequest class in .NET? What is the use of NameValue collection then?
If I check the credentials in the same page (page1.aspx), then I dont need to access the formcollection. I can simply use the ids of these controls right?
So, Is Response.Redirect() the ONLY way to jump to a different page in ASP.NET????
omkamal
|
|
|
|
|
If you want login info in page2.aspx you will probably want it in many more other pages. Just store it in Session variable and check this variable in every page.
Yes since your page1.asp doing all the login stuff you can refer to username textbox as if it was a server object:
if( txtUsername.Text == "blah" )
or
If txtUsername.Text = "blah" Then
you don't have to do Request.Form() stuff.
Server.Transfer() is better than Response.Redirect() because it does not do a round trip to client and back it just transfers control to another page.
|
|
|
|
|
BTW, you can still use client side forms as before just take out runat="server" part in your form tag. But you will not be able to take advantage of all the server side ASP components.
|
|
|
|
|
Now, are we concluding that posting form collection to a different aspx page is not possible???? Thats bad.
May be my login info is needed in different other pages so I can use session variables. But what if I have one variable that I need it only for page2.aspx. I dont have to go to session variable.
Ok. Lets give this up. If you find any info about sending values to a different page please let me know and so do I.
Thanks.
omkamal
|
|
|
|
|
Forms Authentication is now built in to asp.net
you can read about it here:
http://www.gotdotnet.com/quickstart/aspplus/doc/formsauth.aspx
|
|
|
|
|
omkamal wrote:
Then how would I jump to a different page?
Ok if all you want to do is jump to a different page then use response.redirect(), use a normal hyperlink or use javascript.
But I think you mean you want to submit a form, carry over the form data and process it on another page.
Your problem is that you are trying to apply ASP thinking to ASP.NET. The biggest bonus of ASP.NET is that it handles "state" for you. You build a form as per normal, don't worry about the action attribute though, and the submit button is then linked to a procedure (when you build your form just double click the submit button, in the IDE, and you will see). In the procedure you have the code which handles the form data. I just type "strFirstName = frmMain.txtFirstName" in the procedure and it works. ASP.NET handles it all for you.
I recommend you go through The ASP.NET Page Life Cycle and ASP.NET Code Behind Pages, and remember to stop thinking in old ASP terms. ASP.NET is rather different, and RATHER better
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
"The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge
Martin Marvinski wrote:
Unfortunatly Deep Throat isn't my cup of tea
Do you Sonork? I do! 100.9903 Stormfront
|
|
|
|
|
I will certainly give this a try and go through the links that you have sent me. Thanks in advance. But I just wanted to also tell you that I am not using VS.NET beta 2. I am using a text editor to write the code.
omkamal
|
|
|
|
|
omkamal wrote:
I am using a text editor to write the code.
Welcome to the club. Notepad is my best friend.
|
|
|
|
|
If you still want to use a form to post data to a separate page. Insteand of using a button that has runat="server" just use a regular submit button. It can be found under the HTML tab in the editor or use insert <INPUT type="submit" value="Submit"> inside the form tags. It will act as the submit button used to. Sorry I caught this post late.
Joshua
Sonork ID: 100.9944
ICQ: 519642
Hotmail: JoshuaJGuy@hotmail.com
|
|
|
|
|
I'm running on NT4.0sp6 and I recently installed MDAC 2.6. Then I opened an old Web project inside Visual Interdev to find that calls to Server.CreateObject("ADODB.Connection") fail with
"ActiveX component can't create object."
What's going on? I even tried passing "ADODB.Connection.2.6" to CreateObject to no avail. I have a stand-alone VB project that uses ADO and that still works.
My guess is that I need to reinstall something. If so, what exactly?
Thanks,
Alvaro
|
|
|
|
|
Is there a way of quickly finding out which element on the form has the focus?
Happy programming!!
|
|
|
|
|
Wolfram Steinke wrote:
Is there a way of quickly finding out which element on the form has the focus?
I can give you the LONG way of doing it first, then when I figure out the better way then I will tell you that second.
The long way is to place an "onfocus" event on each element on the form. I am sure you have thought of this though, if not just ask again and I will give you the details.
Now I am off to figure out the easy way... I am sure it has something to do with bubbling but the onfocus event does not support it, also it could be done using Behaviours but I do not know how they work, yet... *opens up Homesite and MSDN.Microsoft.com*
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
"The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge
Martin Marvinski wrote:
Unfortunatly Deep Throat isn't my cup of tea
Do you Sonork? I do! 100.9903 Stormfront
|
|
|
|
|
I need to be able to replace the text in an HTML table dynamically. How can this be done with JavaScript (no ActiveX) to request a small file from the server to fill in the text area.
Happy programming!!
|
|
|
|
|
Use an IFRAME and just change it's source. This will only work in IE. You can however use NS LAYER to buffer the external source contents and copy into a DIV or P tag using innerHTML.
Or use IE's data binding technology using the Tabular Data Control (TDC) Data Source Object, which is really cool, but again only works in IE as far as i know
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
I'm looking for someone to test the WAP 'new articles' page:
http://www.codeproject.com/info/wapnew.asp
It works fine in an emulator but I've no WAP unit to actually test it with. Comments or suggestions welcome.
cheers,
Chris Maunder
|
|
|
|
|
Chris, when I get back to SA (3rd Feb) I can check it out on my phone. (not bothered to get a UK sim card or enable international roaming (bloody expensive))
Just remind me.
I agree on the emulator thing though. Some WAP pages we did looked great on emulators but not on the actual phones. Even some emulators made by the phone manufacturer was not perfect. Also the perspective can change things (i.e. from a PC screen to a mobile screen is very different.)
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
Do you Sonork? I do! 100.9903 Stormfront
"The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge
|
|
|
|
|
Thanks mate.
BTW - which emulator do you use? I'm using the Nokia but it's a POS. Incredibly clunky Java (when will companies learn Java is not for GUIs!) and no matter what I do it caches content so it requires a restart each time a page is changed.
cheers,
Chris Maunder
|
|
|
|
|
Well to be frank, and ernest (in New York. umm you have to watch the movie to get that joke. think it is A Long Kiss goodnight, not sure) I have not touched WAP since about 2 months after it came out, i.e. a long time.
From what I remember the emulator I used most was Wapalizer. But as with most it is not always 100% accurate. It is like asking the W3C to validate your HTML. They will say "looks great, good job" but when you view it on IE or Netscape it is a pile of rubbish.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
Do you Sonork? I do! 100.9903 Stormfront
"The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge
|
|
|
|
|
I got the opening page to show on my Siemens C35i, but trying to view any article resulted in "500 Internal server error" and "1001 invalid scheme in URL".
|
|
|
|