Thursday, March 29, 2012
Newbie : Form question !
I use a Unique Identifier data for my website that I get using the
Request["sid"]
That means most of my links are formatted like mypage.aspx?sid=blabla
So, I need to understand how to add the "?sid=blabla" onto a page where I
have a form with several fields
Do I have to add a hidden field to store the blabla ?
Thanks for your help
Stanyou can either add a querystring or have a hidden field (having method as
'Get' will add all the form fields as querystring parameters)..
Regards,
Augustin
"Stan SR" <stan@.pasdepam.netsunset.com> wrote in message
news:%23MWDGKd7GHA.1256@.TK2MSFTNGP04.phx.gbl...
> Hi,
> I use a Unique Identifier data for my website that I get using the
> Request["sid"]
> That means most of my links are formatted like mypage.aspx?sid=blabla
> So, I need to understand how to add the "?sid=blabla" onto a page where I
> have a form with several fields
> Do I have to add a hidden field to store the blabla ?
>
> Thanks for your help
> Stan
>
>
>
Yes. I have no doubt about this, but how to set the variable as a
queryString parameter when a page is Loaded ?
here's my case :
<form id="form1" runat="server>
<asp:CheckBox id="b" runat="server" text="test" />
</form>
In my codeBehind, I check if a "sid" url parameter is transmitted.
If not I generate one.
And I would like to place it a url parameter.
When I look at the source, I get this
<form name="form1" method="post" action="mypage.aspx" id="form1">
<input id="b" name="b"><label for "b">test</label>
</form>
What I need is to get
<form name="form1" method="post" action="mypage.aspx?sid=blabla" id="form1">
Stan
"Augustin Prasanna"
> you can either add a querystring or have a hidden field (having method as
> 'Get' will add all the form fields as querystring parameters)..
> Regards,
> Augustin
> "Stan SR" <stan@.pasdepam.netsunset.com> wrote in message
> news:%23MWDGKd7GHA.1256@.TK2MSFTNGP04.phx.gbl...
>
> What I need is to get
> <form name="form1" method="post" action="mypage.aspx?sid=blabla" id="form1">[/colo
r]
You could set this in Page.Form.Attributes or use the PostBackUrl
property of your submit button to send the form to the new URL.
Tim
Newbie : Form question !
I use a Unique Identifier data for my website that I get using the
Request["sid"]
That means most of my links are formatted like mypage.aspx?sid=blabla
So, I need to understand how to add the "?sid=blabla" onto a page where I
have a form with several fields
Do I have to add a hidden field to store the blabla ?
Thanks for your help
Stanyou can either add a querystring or have a hidden field (having method as
'Get' will add all the form fields as querystring parameters)..
Regards,
Augustin
"Stan SR" <stan@.pasdepam.netsunset.comwrote in message
news:%23MWDGKd7GHA.1256@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
Hi,
>
I use a Unique Identifier data for my website that I get using the
Request["sid"]
That means most of my links are formatted like mypage.aspx?sid=blabla
>
So, I need to understand how to add the "?sid=blabla" onto a page where I
have a form with several fields
>
Do I have to add a hidden field to store the blabla ?
>
>
Thanks for your help
>
Stan
>
>
>
>
>
Yes. I have no doubt about this, but how to set the variable as a
queryString parameter when a page is Loaded ?
here's my case :
<form id="form1" runat="server>
<asp:CheckBox id="b" runat="server" text="test" />
</form>
In my codeBehind, I check if a "sid" url parameter is transmitted.
If not I generate one.
And I would like to place it a url parameter.
When I look at the source, I get this
<form name="form1" method="post" action="mypage.aspx" id="form1">
<input id="b" name="b"><label for "b">test</label>
</form>
What I need is to get
<form name="form1" method="post" action="mypage.aspx?sid=blabla" id="form1">
Stan
"Augustin Prasanna"
Quote:
Originally Posted by
you can either add a querystring or have a hidden field (having method as
'Get' will add all the form fields as querystring parameters)..
>
Regards,
Augustin
>
"Stan SR" <stan@.pasdepam.netsunset.comwrote in message
news:%23MWDGKd7GHA.1256@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
>Hi,
>>
>I use a Unique Identifier data for my website that I get using the
>Request["sid"]
>That means most of my links are formatted like mypage.aspx?sid=blabla
>>
>So, I need to understand how to add the "?sid=blabla" onto a page where I
>have a form with several fields
>>
>Do I have to add a hidden field to store the blabla ?
>>
>>
>Thanks for your help
>>
>Stan
>>
>>
>>
>>
>>
>
>
What I need is to get
Quote:
Originally Posted by
<form name="form1" method="post" action="mypage.aspx?sid=blabla" id="form1">
You could set this in Page.Form.Attributes or use the PostBackUrl
property of your submit button to send the form to the new URL.
Tim
Monday, March 26, 2012
Newbie Advice: UserInteractive mode
I am new to ASP.NET making the move over from windows forms development.
In Windows forms I used to throw an error to a windows form or a message box when I wanted to alert the user about something i.e. invalid password on login.
I would like to know if it is better to place the application into "UserInteractive mode" and use standard dialog boxes or should i be creating pages to report such things.
Any applications I produce will be restricted to the local Intranet.
Any advice appreciated.You can't use standard dialog boxes in a webpage as these are for windows forms (well ok you can get them to work in a sense but they will only display on the server which wouldn't be any good to you).
For small messages such as 'login details not recognised' I'd just display them in a label on the page (I know as a user i'd also prefer this than rather having to close a messagebox everytime).
For application errors incorporate error handling to catch them.
Hi,
many thanks for your response.
Of course you are correct, I forgot that this will now be server based rather than client as I am used to. I didn't consider that the dialogs would appear local to the server.
I will go down the path of using alert screens/labels to return responses to the end user.
Thank you
It'll be simple. You'll use
Page.RegisterStartupScript("myalert","<script language='JavaScript'>alert('" + somevariable + "');</script>");
Saturday, March 24, 2012
newbie debug asp
been developing some growing .asp programs that do form processing, running
on a different machine, iis5.0,
and would like to be able to run/debug those under my visual studio
environment, so embarrassed
to say don't even know at this point if its possible, so thats the big
question
and then if thats possible, can i simulate the data being passed from the
web page form for testing the asp program??"bbxrider" <bxtrap01@.comcast.net> wrote in message
news:%238wtxmVaFHA.3400@.tk2msftngp13.phx.gbl...
>i have .net2002/visual studio and have only used it so far for vb.net
> been developing some growing .asp programs that do form processing,
> running
> on a different machine, iis5.0,
> and would like to be able to run/debug those under my visual studio
> environment, so embarrassed
> to say don't even know at this point if its possible, so thats the big
> question
> and then if thats possible, can i simulate the data being passed from the
> web page form for testing the asp program??
Hi,
If you are talking about debugging Classic ASP, it's a freakin nightmare.
If I were you, I wouldn't waste my time. Just fill your code full of
Response.Write()s ... that is actually a hell of a lot more effecient.
THANK GOD for .NET!!!
--
Regards,
John MacIntyre
http://www.johnmacintyre.ca
Specializing in; Database, Web-Applications, and Windows Software
thanks for the reply
i have been using the response.write technique, but ran into some kind of
problem, i think because i executed
wscipt.createobject instead of server.createobject and then could not run
any asp! had to reboot, so was trying
to get around that
is it possible then to rewrite the old asp into asp.net and run that on my
win2k/iis5.0 server??
bbx
"John" <Please.Reply@.To.the.group.com> wrote in message
news:uUovjTWaFHA.3808@.TK2MSFTNGP14.phx.gbl...
> "bbxrider" <bxtrap01@.comcast.net> wrote in message
> news:%238wtxmVaFHA.3400@.tk2msftngp13.phx.gbl...
> >i have .net2002/visual studio and have only used it so far for vb.net
> > been developing some growing .asp programs that do form processing,
> > running
> > on a different machine, iis5.0,
> > and would like to be able to run/debug those under my visual studio
> > environment, so embarrassed
> > to say don't even know at this point if its possible, so thats the big
> > question
> > and then if thats possible, can i simulate the data being passed from
the
> > web page form for testing the asp program??
> Hi,
> If you are talking about debugging Classic ASP, it's a freakin nightmare.
> If I were you, I wouldn't waste my time. Just fill your code full of
> Response.Write()s ... that is actually a hell of a lot more effecient.
> THANK GOD for .NET!!!
>
> --
> Regards,
> John MacIntyre
> http://www.johnmacintyre.ca
> Specializing in; Database, Web-Applications, and Windows Software
"bbxrider" <bxtrap01@.comcast.net> wrote in message
news:u2j9zlWaFHA.464@.TK2MSFTNGP15.phx.gbl...
> is it possible then to rewrite the old asp into asp.net and run that on my
> win2k/iis5.0 server??
> bbx
I have asp.net running on a Win2k/IIS5 machine without problems.
thanks again, sounds like my next project
"John" <Please.Reply@.To.the.group.com> wrote in message
news:%23165n2WaFHA.1456@.TK2MSFTNGP15.phx.gbl...
> "bbxrider" <bxtrap01@.comcast.net> wrote in message
> news:u2j9zlWaFHA.464@.TK2MSFTNGP15.phx.gbl...
> > is it possible then to rewrite the old asp into asp.net and run that on
my
> > win2k/iis5.0 server??
> > bbx
>
> I have asp.net running on a Win2k/IIS5 machine without problems.
>
>
>
newbie debug asp
been developing some growing .asp programs that do form processing, running
on a different machine, iis5.0,
and would like to be able to run/debug those under my visual studio
environment, so embarrassed
to say don't even know at this point if its possible, so thats the big
question
and then if thats possible, can i simulate the data being passed from the
web page form for testing the asp program'"bbxrider" <bxtrap01@.comcast.net> wrote in message
news:%238wtxmVaFHA.3400@.tk2msftngp13.phx.gbl...
>i have .net2002/visual studio and have only used it so far for vb.net
> been developing some growing .asp programs that do form processing,
> running
> on a different machine, iis5.0,
> and would like to be able to run/debug those under my visual studio
> environment, so embarrassed
> to say don't even know at this point if its possible, so thats the big
> question
> and then if thats possible, can i simulate the data being passed from the
> web page form for testing the asp program'
>
Hi,
If you are talking about debugging Classic ASP, it's a freakin nightmare.
If I were you, I wouldn't waste my time. Just fill your code full of
Response.Write()s ... that is actually a hell of a lot more effecient.
THANK GOD for .NET!!!
Regards,
John MacIntyre
http://www.johnmacintyre.ca
Specializing in; Database, Web-Applications, and Windows Software
thanks for the reply
i have been using the response.write technique, but ran into some kind of
problem, i think because i executed
wscipt.createobject instead of server.createobject and then could not run
any asp! had to reboot, so was trying
to get around that
is it possible then to rewrite the old asp into asp.net and run that on my
win2k/iis5.0 server'
bbx
"John" <Please.Reply@.To.the.group.com> wrote in message
news:uUovjTWaFHA.3808@.TK2MSFTNGP14.phx.gbl...
> "bbxrider" <bxtrap01@.comcast.net> wrote in message
> news:%238wtxmVaFHA.3400@.tk2msftngp13.phx.gbl...
the
> Hi,
> If you are talking about debugging Classic ASP, it's a freakin nightmare.
> If I were you, I wouldn't waste my time. Just fill your code full of
> Response.Write()s ... that is actually a hell of a lot more effecient.
> THANK GOD for .NET!!!
>
> --
> Regards,
> John MacIntyre
> http://www.johnmacintyre.ca
> Specializing in; Database, Web-Applications, and Windows Software
>
"bbxrider" <bxtrap01@.comcast.net> wrote in message
news:u2j9zlWaFHA.464@.TK2MSFTNGP15.phx.gbl...
> is it possible then to rewrite the old asp into asp.net and run that on my
> win2k/iis5.0 server'
> bbx
I have asp.net running on a Win2k/IIS5 machine without problems.
thanks again, sounds like my next project
"John" <Please.Reply@.To.the.group.com> wrote in message
news:%23165n2WaFHA.1456@.TK2MSFTNGP15.phx.gbl...
> "bbxrider" <bxtrap01@.comcast.net> wrote in message
> news:u2j9zlWaFHA.464@.TK2MSFTNGP15.phx.gbl...
my
>
> I have asp.net running on a Win2k/IIS5 machine without problems.
>
>
>
>
newbie dropdownlist question
I have an employee details form for an intranet to a sql server database. A number of controls in the form will be dropdown lists used as lookups. ie I have a jobno in the employee
table which would be linked to a jobsid in a jobs table. The only table which would be updated is the employee table.
I am using a separate datasets. I cant set the datatext to jobs.id and the datavalue to employee.jobno
The item shown in the list would be the employees id.
I don't know if the dataset would be the corect method?
Any assistance greatly appreciated.Write a query/view (woteva) using links to retrieve the required data for the dropdownlist and populate it into the same DataSet.
Newbie Email
New to .Net - using the 4Guys example to send email form data via email.
I'm getting stuck though when trying to add more fields to form and therefore the actual email sent.
Any help would be grateful!!
Code below :
<script language="vb" runat="server"
Sub btnSendFeedback_Click(sender as Object, e as EventArgs)
'Create an instance of the MailMessage class
Dim objMM as New MailMessage()
'Set the properties - send the email to the person who filled out the
'feedback form.
objMM.To = "me@dotnet.itags.org.mydomain"
objMM.From = txtEmail.Text
'If you want to CC this email to someone else, uncomment the line below
'objMM.Cc = "someone@dotnet.itags.org.someaddress.com"
'If you want to BCC this email to someone else, uncomment the line below
'objMM.Bcc = "someone@dotnet.itags.org.someaddress.com"
'Send the email in text format
objMM.BodyFormat = MailFormat.Text
'(to send HTML format, change MailFormat.Text to MailFormat.Html)
'Set the priority - options are High, Low, and Normal
objMM.Priority = MailPriority.Normal
'Set the subject
objMM.Subject = "Email Test"
'Set the body
objMM.Body = txtName.Text & vbCrLf _ txtPhone.Text & vbCrLf _ txtComments.Text & vbCrLf _ txtEmail.Text
'Specify to use the default Smtp Server
SmtpMail.SmtpServer = "mymailserver"
'Now, to send the message, use the Send method of the SmtpMail class
SmtpMail.Send(objMM)
panelSendEmail.Visible = false
panelMailSent.Visible = true
End Sub
</script
<asp:panel id="panelSendEmail" runat="server">
<form runat="server">
<p>We are interested in your feedback! Please enter the following
requested information below to send us your comments.</p>
<p>Your Name:
<asp:textbox id="txtName" runat="server" /></p>
<p>Your Email Address:
<asp:textbox id="txtEmail" runat="server" /></p>
<p>Your Phone Number:
<asp:textbox id="txtPhone" runat="server" /></p>
<p>Your Message:</p>
<p><asp:textbox id="txtComments" TextMode="MultiLine"
Columns="40" Rows="10" runat="server" /></p>
<p> <asp:button runat="server" id="btnSendFeedback" Text="Send Feedback!"
OnClick="btnSendFeedback_Click" /></p>
</form>
</asp:panel>
<asp:panel id="panelMailSent" runat="server" Visible="False">
<p>An email has been sent to the email address you specified. Thanks!</p>
</asp:panel>Hi,
nice code but what exactly is the error you experience? Did the code you copied from the site of 4guys work on your system before you altered the code?
Grz, Kris.
Kris,
Many thanks for your reply...
The problem i am having (and have tried many variations to correct) is with the objMMbody and declaring what to send to the mail recepient.
If i change the code to this :
<code
'Set the body
objMM.Body = txtName.text + txtPhone.text + txtComments.text + txtEmail.text
<code/
It works fine.
But i want to be able to add headers for the form data such as "Name: txtName.text" with a CR to make it neat to the end user.
Help!!
TIA
This might help:http://www.systemwebmail.com/faq/2.8.aspx.
Thanks for the URL but this is not what i am trying to achieve as per my last post...all i think i need to know is the syntax for separating by a <CR> the form data in the email that i want to send...i have tried vbCRLF and chr13 etc but not in the correct way i think...
TIA
Hi Jezzer,
try this one out:Environment.NewLine Property.
Grz, Kris.
Newbie Error....
This is the error I get so far...
http://www.jetha.ca/wwwroot/TESTApp/WebForm1.aspx
any thoughts?
Thanks in advance,
GREAT SITE BTW, I think I am going to be here often...
Dee...As I know If the application is not build properly, then assembly won't exist, in that case you will get this error
You can get info on this error at MS Support @.http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306155
Hope it helps!
Thanks for the link, but I rebuilt it, and copied over to the server, and I still get the same error...
This is brand new for me, I am not sure if it is the server or my builds or something else...
Is there something I need to set up on the IIS on the server?
Ok, I got it, my global.aspx file was too many folders down, and it could not find it...I dropped the app in the root directory, and it works...
http://www.jetha.ca/WebForm1.aspx
YAYA!!!!
My first ASP.NET Application... Pretty good eh?
Great!!! Hope you will enjoy using asp.net!
Enjoy while using asp.net and be patient if you get any errors ; )
It's a very wonderful product!
I am sure I will...baby steps right, baby steps...
Thanks again for responding...
Newbie Form Question
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write("Reciprocal link: " + reciplink.Text);
Response.Write("<br>");
Response.Write("Customer website: " + custurl.Text);
Response.Write("<br>");
Response.Write("Customer title: " + custtitle.Text);
}
Problem is that when I display these values on the web page the input boxes and original form are still there. So the values are be written on top of the previous form. How do you clear the contents of the web page so that when the end user clicks a submit button they see ONLY the values they entered. Do you spawn a new page or ?One thing you can do is set the Visible property of web controls to false.
reciplink.Visible = false;
custurl.Visible = false;
custtitle.Visible = false;
Hi,
using response.write is not such a good idea to show information to your users because it writes everything before the opening html tag.
Rather use a label control or literal control for this and set the Text property.
I cooked up a little piece of code to demonstrate what I mean:
Some extra information: I placed the textbox and button control in a panel control so I only have to set the visibility of this 1 control instead of setting this property of every control (I'm on vacation right now so I'm a bit lazy ;-) ).
<%@. Page Language="C#" %>
<script runat="server"
void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Your input was: " + TextBox1.Text.Trim();
Panel1.Visible = false;Response.Write(Label1.Text);
}</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<asp:Panel id="Panel1" runat="server">
<p>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
</p>
<p>
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Button"></asp:Button>
</p>
</asp:Panel>
</p>
<p>
<asp:Label id="Label1" runat="server"></asp:Label>
</p>
</form>
</body>
</html>
When you take a look at the rendered page source in your browser (view | Source) you'll see the text "Your input was: ..." appear on the first line in the html by this breaking the code. This comes from the response.write. It used to be a mechanism in classic asp but nowadays we havetracing for that.
Grz, Kris.
Thanks for your response. I do not understand where you are writing the variable to page. Obviously I get the response.write but using the panel I still do not get it. I have played around and can see how placing objects on one panel and then setting it to false will remove all the input boxes. But how are you returning data to the browser without a response statement??
Also this statement:
<asp:Label id="Label1" runat="server"></asp:Label
Is this essentially just initializing a variable so that you can use it in the c# function?
When I run my code using your suggestion the panel does disappear but I do not get any out put like yours?
this is what I am using:
private void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Your input was: " + TextBox1.Text.Trim();
Panel1.Visible = false;
}
AsP.Net is event driven and object oriented - - in any given event, you assign text to the text property of a label (an object) - - that, in turn, is displayed on the screen.
your label isn't inside the panel is it?
if you make the panel invisible and the label's inside the panel, the label will be invisible also.
Something like this: (im using a codebehind page for everything i do)
test.aspx
<%@. Page language="c#" src="http://pics.10026.com/?src=test.aspx.cs" AutoEventWireup="true" Inherits="xtest.test" %>
<HTML>
<HEAD>
<title>Test</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:panel id="InputFields" runat="server" Visible="false">
<P>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox></P>
<P>
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Button"></asp:Button></P>
</asp:panel><asp:panel id="Result" runat="server" Visible="false">
<P>
<asp:Label id="Label1" runat="server"></asp:Label></P>
</asp:panel></form>
</body>
</HTML>
test.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace xtest
{
public class test : System.Web.UI.Page
{protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Panel InputFields;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Panel Result;private void Page_Load(object sender, System.EventArgs e)
{
if ( ! Page.IsPostBack )
{
InputFields.Visible = true;
Result.Visible = false;
}
}public void Button1_Click(object sender, System.EventArgs e)
{
InputFields.Visible = false;
Result.Visible = true;Label1.Text = TextBox1.Text.Trim();
}
}
}
That's it. I had the label inside the panel, duh! Thanks. From a best practices standpoint, would you recommend using web controls on a panel as above for most of your user input pages? In turn you could place multiple panels on a particluar page for more flexibility etc?
Hi,
you can place multiple panels on your page or you could use user controls or create your own composite controls.
That's just the big advantage and sometimes even the big disadvantage of ASP.NET: you've got a lot of freedom to do what you want to do. And just like a kid that needs to learn responsibility a developer using ASP.NET needs some time to find out which methodolgy is the best way for solving a particular problem.
Grz, Kris.
newbie form post question
the post method.
The posting page is HTML and I won't know what's in it ahead of time...
How can I get a item/value pair for it.
I'm sure it is simple but haven't figured it out.
Thanks
ShaneWould somethin glike this work?:
Dim idict As System.Collections.IDictionaryEnumerator = CType(Request.Form,
System.Collections.IDictionaryEnumerator)
While idict.MoveNext
Dim key As String = CStr(idict.Key)
Dim value As String = CStr(idict.Value)
End While
Karl
"SStory >" <Shane_Story@.online.msn.com <remove the 'online.' to send me
mail> wrote in message news:%23i9iyr5VDHA.2544@.tk2msftngp13.phx.gbl...
> Please tell me how I can get the values and items for a form posted using
> the post method.
> The posting page is HTML and I won't know what's in it ahead of time...
> How can I get a item/value pair for it.
> I'm sure it is simple but haven't figured it out.
> Thanks
> Shane
give me this...
Specified cast is not valid.
I can't imagine why this should be so ridiculous nor can I found information
on it.
I need info from an HTML page, not the same ASPX page and it will be POST
instead of GET.
I looked at request.form.key, .getvalues.
Not sure what they do and can't find explanation
if you have any more ideas please let me know..
Thanks a bunch,
Shane
"Karl Seguin" <kseguin##crea.ca> wrote in message
news:OJJS1v5VDHA.2364@.TK2MSFTNGP09.phx.gbl...
> Would somethin glike this work?:
> Dim idict As System.Collections.IDictionaryEnumerator =
CType(Request.Form,
> System.Collections.IDictionaryEnumerator)
> While idict.MoveNext
> Dim key As String = CStr(idict.Key)
> Dim value As String = CStr(idict.Value)
> End While
> Karl
> "SStory >" <Shane_Story@.online.msn.com <remove the 'online.' to send me
> mail> wrote in message news:%23i9iyr5VDHA.2544@.tk2msftngp13.phx.gbl...
> > Please tell me how I can get the values and items for a form posted
using
> > the post method.
> > The posting page is HTML and I won't know what's in it ahead of time...
> > How can I get a item/value pair for it.
> > I'm sure it is simple but haven't figured it out.
> > Thanks
> > Shane
Request.Form is a NameValueCollection, containing the names and values of
all the form fields in the form that posted to the current Page. All you
have to do is iterate through it.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.
"SStory >" <Shane_Story@.online.msn.com <remove the 'online.' to send me
mail> wrote in message news:%23i9iyr5VDHA.2544@.tk2msftngp13.phx.gbl...
> Please tell me how I can get the values and items for a form posted using
> the post method.
> The posting page is HTML and I won't know what's in it ahead of time...
> How can I get a item/value pair for it.
> I'm sure it is simple but haven't figured it out.
> Thanks
> Shane
Thanks a million... Whew... The docs said it lists all forms on a page so I
was thrown off..
for anybody else who needs to know the easy way of doing this is:
dim i as short
For i = 0 To Request.Form.Count - 1
Response.Write(Request.Form.Keys(i) & "=" & Request.Form.Item(i) & &
"</br>")
Next i
"Kevin Spencer" <kevin@.takempis.com> wrote in message
news:uB31615VDHA.2368@.TK2MSFTNGP09.phx.gbl...
> Request.Form is a NameValueCollection, containing the names and values of
> all the form fields in the form that posted to the current Page. All you
> have to do is iterate through it.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> http://www.takempis.com
> Complex things are made up of
> lots of simple things.
> "SStory >" <Shane_Story@.online.msn.com <remove the 'online.' to send me
> mail> wrote in message news:%23i9iyr5VDHA.2544@.tk2msftngp13.phx.gbl...
> > Please tell me how I can get the values and items for a form posted
using
> > the post method.
> > The posting page is HTML and I won't know what's in it ahead of time...
> > How can I get a item/value pair for it.
> > I'm sure it is simple but haven't figured it out.
> > Thanks
> > Shane
Newbie has coding problem (2 Qs)
Code follows, then compiler error. Q. What is the better way to test for a null record? I know my HasRec variable is bad coding, but unsure how to use Isnull in C# against a SQL record.
<%@dotnet.itags.org. Page Language="c#" %>
<%@dotnet.itags.org. Register TagPrefix="portal" TagName="Banner" src="http://pics.10026.com/?src=~/DesktopPortalBanner.ascx" %>
<script runat="server"
int HasRec = 0;void Page_Load(int userID)
{// Check to see if data is in this userID rec and display if so
// create instance {new?}SqlDataReader dr = profile.GetVolunteerProfilePageOne(UserID);
dr.read()
SalutationDropDownList.Text = (string) dr["Salutation"];
FirstNameTextBox.Text = (string) dr["Firstname"];
MiddlenameTextBox.Text = (string) dr["Middlename"];
LastnameTextBox.Text = (string) dr["Lastname"];
SuffixTextBox.Text = (string) dr["Suffix"];
AddressTextBox.Text = (string) dr["Address"];
AptNumberTextBox.Text = (string) dr["AptNumber"];
ZIPTextBox.Text = (int) dr["Zip"];
JurisdictionDropDownList.Text = (string) dr ["Jurisdiction"];
StateTextBox.Text = (string) dr["State"];
POBoxTextBox.Text = (string) dr["POBox"];
DOBTextBox.Text = (string) dr["DOB"];
SocialSecurityTextBox.Text = (string) dr["SocialSecurity"];if Lastname != null {
HasRec = 1;
}// Close datareader
dr.Close();}
}
void FirstRegPageButton_Click(object sender, EventArgs e) {
if Hasrec = 0 {
// Add the profile within the profile table
profile.CreateVolunteerProfilePageOne ( UserID, SalutationDropDownList.Text, FirstNameTextBox.Text, MiddleNameTextBox.Text, LastNameTextBox.Text, SuffixTextBox.Text, AddressTextBox.Text, AptNumberTextBox.Text, ZIPTextBox.Int, JurisdictionDropdownList.Selection, StateTextBox.Text, POBoxTextBox.Text, DOBTextBox.Text, SocialSecurityTextBox.Text);
}
else {// Update the contact within the contacts table
profile.UpdateVolunteerProfilePageOne ( UserID, SalutationDropDownList.Text, FirstNameTextBox.Text, MiddleNameTextBox.Text, LastNameTextBox.Text, SuffixTextBox.Text, AddressTextBox.Text, AptNumberTextBox.Text, ZIPTextBox.Int, JurisdictionDropdownList.Selection, StateTextBox.Text, POBoxTextBox.Text, DOBTextBox.Text, SocialSecurityTextBox.Text);
}
}void Cancel_Click(object sender, EventArgs e) {
}
</script
Compiler Error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0116: A namespace does not directly contain members such as fields or methods
Source Error:
Line 48: }
Line 49:
Line 50: void FirstRegPageButton_Click(object sender, EventArgs e) {
Line 51:
Line 52:
Source File: C:\Portal\PortalCSSDK\DesktopModules\VolRegistration.aspx Line: 50You are getting the compilation error because you have an extra closing bracket "}" at line 48 - remove it and it should work.
Hope that helps
Kashif
You can test for a null record with a SqlDataReader by the Read method's return value.
bool noRecords = dr.Read()
If noRecords is false, then there are no more records at the current position in the reader.
The way to test for a null field in a record is to test against DBNull.Value.
if (dr["LastName"] == DBNull.Value)
//field is null
NEWBIE HELP
Hi All
I have a web form that uses an object class to populate a standard table (not datagrid etc)
I have a button on this form that when clicked opens another form for editing. In this form all the values of the object are used to populate text boxes (in the load event of the form there is a call to a DBHelper class which uses a SQL Parameter Array to execute a strored procedure (SQL) and return the data) and text areas which are free to edit in this form.
Also on this page I have a button called save changes which when clicked I am attempting to create a new paramater array to execute an update procedure again using the DBHelper Class.
Unfortunately when I try to do this the values in the new SQLParamater Array are exactly the same as before and are not reflecting the changes that I make by typing new entries into the text boxes on the form. As a newbie to .net I am lost here and realise that this is probably a scope or state problem but I would like someone to point me in the right direction please. When I hard wire the new SQLParamater Array the update does work so that eliminates the chances of the DBHelper Class from any fault.
Please help as I am going bonkers here!!!!!
Phill
You probably have your "populate form" bit in your Page Load function - which will execute when the save button causes a post back.
Surround your "populate the textboxes" code with:
if (!IsPostBack)
{
...
}
This will mean it only runs when the page is first loaded.
Have you looked if your sql update statement is passing the values as @.new_value
I would recommend doing this on a datagrid, it would be easier to update cuz the datagrid already has an update command field!
I cant use a datagrid as the recordset only ever returns one row with 17 fields. Datagrids need multirows to work dont they?
Datagrids work with "a number" of rows - that can be one row.
welshpunk:
I cant use a datagrid as the recordset only ever returns one row with 17 fields. Datagrids need multirows to work dont they?
Hi welshpunk,
Try to follow those codes as follows:
Working with a Single Table
http://msdn2.microsoft.com/en-us/library/aa719548(VS.71).aspx
Thanks.
Yes but you cannot turn a datagrid on its side. I have 17 fields in the recordset(just one row) Using a datagrid in this fashion is not user friendly as some of the fields are up to 2000 chars long. Datagrids will display like this
Column Heading Column Heading Column Heading Column Heading Column Heading
Data Data Data Data Data
I want to display the data in a more user friendly way like this
Column Header Data
Column Header Data
Column Header Data
Column Header Data
Column Header Data
Column Header Data
Column Header Data
With the 17 column headers on the left and their respective data adjacent to them. This is why I had to create the form in this way.
Hi,
You can write each cell every time by reading each cell once.
Hope this helps.
I have already marked as answer
Don't worry - you'll soon see that comment about marking posts as the answer absolutely everywhere!
You could try using a detailsview. The data would be displayed the way you want.
Newbie Help (Parser Error)
The default.aspx page simply displays a form and a heading:
PAGE CODE:
------
<%@dotnet.itags.org. Page Language="VB" %>
<html>
<body>
<form id='form1' method='post' runat='server'>
<h1> Welcome to First Application</h1>
<asp:button id='btnNavigate' runat='server' text='Navigate'/>
</form>
</body>
</html
--------
When I run the application I get the following error.
ERROR MESSAGE:
--------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'firstapp.Global'.
Source Error:
Line 1: <%@dotnet.itags.org. Application Codebehind="Global.asax.vb" Inherits="firstapp.Global" %
Source File: c:\inetpub\wwwroot\firstapp\global.asax Line: 1
-------------------
I am not sure why. The application was install as an asp.net application on IIS 5.
Any help would be greatly appreciated. My email is tcornett@dotnet.itags.org.ci.kingman.az.us
Thanks,
Terry C.There are several files required for an ASP.NET web app:
1. Your web form(s)
2. The web.config file
3. The Global.asax file
The Global.asax file must define a class called Global, subclassed from httpApplication. It appears that you have defined a Global.asax file and it refers to a code behind file that should define that Global class. Most likely, you have not compiled the file Global.asax.vb into an assembly that is part of your \bin folder. (All .vb files can be compiled into one single assembly. If you are using Visual Studio.net, that should happen automatically, assembling Global.asax is in your solution and it's Build Action property is set to "Compile".)
Thanks Peter.
I did not realize I had to build the solution for such a simple test web application. The book I was using as a reference did not mention that.
Once I built the solution it worked.
Thanks again for the help.
Terry C. :-)
Thursday, March 22, 2012
Newbie master/detail question
newbie navigation/form re-draw issue...
be accomplished by doing a post from one page to another page.
If a webform as fields for user information (address, name, phone,
etc) and a submit button... What is the best way in asp.net to
re-display the information and ask the user to verify the info is
correct.
Will I do a post back to the same webform, remove the previous web
server controls and redraw the page w/ the new information?
Would it be best to transfer to a new page (via Response.Redirect
(url) or Server.Transfer (url)) and get the information from the first
webform?
thanks,
rogerIt's probably easiest to do something like posting the data to a new form
which will display it to the user and ask for confirmation. You could also
write your original page to check for whether this is a postback or not,
and then generate the form's target and the data fields on the fly.
Assuming your page is "page1.aspx" it might be something like:
<some header information>
...
if (isPostBack = true) then
Response.Write("Please confirm the data and hit sumbit again (or some
other message)");
endif
if (isPostBack = true) then
response.write("<form method=post target=page2.aspx");
else
response.write("<form method=post target=page1.aspx");
endif
Then, when writing out your textboxes and other input forms, you can check
to see if ispostback = true and it it is, you can populate the value
appropriately from the request object.
</form
Just a thought,
Chris
-------
>From: roger_beniot@.yahoo.com (roger beniot)
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>Subject: newbie navigation/form re-draw issue...
>Date: 6 Apr 2004 12:12:53 -0700
>Organization: http://groups.google.com
>Lines: 18
>Message-ID: <6c7aa9be.0404061112.30a2134f@.posting.google.com>
>NNTP-Posting-Host: 12.129.11.151
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 8bit
>X-Trace: posting.google.com 1081278773 7573 127.0.0.1 (6 Apr 2004 19:12:53
GMT)
>X-Complaints-To: groups-abuse@.google.com
>NNTP-Posting-Date: Tue, 6 Apr 2004 19:12:53 +0000 (UTC)
>Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.sul.t-online.de!t-onlin
e.de!news.glorb.com!postnews1.google.com!not-for-mail
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:224021
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>I'm trying to figure out how to do something in ASP.NET that used to
>be accomplished by doing a post from one page to another page.
>If a webform as fields for user information (address, name, phone,
>etc) and a submit button... What is the best way in asp.net to
>re-display the information and ask the user to verify the info is
>correct.
>Will I do a post back to the same webform, remove the previous web
>server controls and redraw the page w/ the new information?
>Would it be best to transfer to a new page (via Response.Redirect
>(url) or Server.Transfer (url)) and get the information from the first
>webform?
>
>thanks,
>roger
newbie navigation/form re-draw issue...
be accomplished by doing a post from one page to another page.
If a webform as fields for user information (address, name, phone,
etc) and a submit button... What is the best way in asp.net to
re-display the information and ask the user to verify the info is
correct.
Will I do a post back to the same webform, remove the previous web
server controls and redraw the page w/ the new information?
Would it be best to transfer to a new page (via Response.Redirect
(url) or Server.Transfer (url)) and get the information from the first
webform?
thanks,
rogerIt's probably easiest to do something like posting the data to a new form
which will display it to the user and ask for confirmation. You could also
write your original page to check for whether this is a postback or not,
and then generate the form's target and the data fields on the fly.
Assuming your page is "page1.aspx" it might be something like:
<some header information>
...
if (isPostBack = true) then
Response.Write("Please confirm the data and hit sumbit again (or some
other message)");
endif
if (isPostBack = true) then
response.write("<form method=post target=page2.aspx");
else
response.write("<form method=post target=page1.aspx");
endif
Then, when writing out your textboxes and other input forms, you can check
to see if ispostback = true and it it is, you can populate the value
appropriately from the request object.
</form
Just a thought,
Chris
-------
>From: roger_beniot@.yahoo.com (roger beniot)
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>Subject: newbie navigation/form re-draw issue...
>Date: 6 Apr 2004 12:12:53 -0700
>Organization: http://groups.google.com
>Lines: 18
>Message-ID: <6c7aa9be.0404061112.30a2134f@.posting.google.com>
>NNTP-Posting-Host: 12.129.11.151
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 8bit
>X-Trace: posting.google.com 1081278773 7573 127.0.0.1 (6 Apr 2004 19:12:53
GMT)
>X-Complaints-To: groups-abuse@.google.com
>NNTP-Posting-Date: Tue, 6 Apr 2004 19:12:53 +0000 (UTC)
>Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.sul.t-online.de!t-onlin
e.de!news.glorb.com!postnews1.google.com!not-for-mail
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:224021
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>I'm trying to figure out how to do something in ASP.NET that used to
>be accomplished by doing a post from one page to another page.
>If a webform as fields for user information (address, name, phone,
>etc) and a submit button... What is the best way in asp.net to
>re-display the information and ask the user to verify the info is
>correct.
>Will I do a post back to the same webform, remove the previous web
>server controls and redraw the page w/ the new information?
>Would it be best to transfer to a new page (via Response.Redirect
>(url) or Server.Transfer (url)) and get the information from the first
>webform?
>
>thanks,
>roger
It's probably easiest to do something like posting the data to a new form
which will display it to the user and ask for confirmation. You could also
write your original page to check for whether this is a postback or not,
and then generate the form's target and the data fields on the fly.
Assuming your page is "page1.aspx" it might be something like:
<some header information>
...
if (isPostBack = true) then
Response.Write("Please confirm the data and hit sumbit again (or some
other message)");
endif
if (isPostBack = true) then
response.write("<form method=post target=page2.aspx");
else
response.write("<form method=post target=page1.aspx");
endif
Then, when writing out your textboxes and other input forms, you can check
to see if ispostback = true and it it is, you can populate the value
appropriately from the request object.
</form
Just a thought,
Chris
-------
>From: roger_beniot@.yahoo.com (roger beniot)
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>Subject: newbie navigation/form re-draw issue...
>Date: 6 Apr 2004 12:12:53 -0700
>Organization: http://groups.google.com
>Lines: 18
>Message-ID: <6c7aa9be.0404061112.30a2134f@.posting.google.com>
>NNTP-Posting-Host: 12.129.11.151
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 8bit
>X-Trace: posting.google.com 1081278773 7573 127.0.0.1 (6 Apr 2004 19:12:53
GMT)
>X-Complaints-To: groups-abuse@.google.com
>NNTP-Posting-Date: Tue, 6 Apr 2004 19:12:53 +0000 (UTC)
>Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.sul.t-online.de!t-onlin
e.de!news.glorb.com!postnews1.google.com!not-for-mail
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:224021
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>I'm trying to figure out how to do something in ASP.NET that used to
>be accomplished by doing a post from one page to another page.
>If a webform as fields for user information (address, name, phone,
>etc) and a submit button... What is the best way in asp.net to
>re-display the information and ask the user to verify the info is
>correct.
>Will I do a post back to the same webform, remove the previous web
>server controls and redraw the page w/ the new information?
>Would it be best to transfer to a new page (via Response.Redirect
>(url) or Server.Transfer (url)) and get the information from the first
>webform?
>
>thanks,
>roger
newbie navigation/form re-draw issue...
be accomplished by doing a post from one page to another page.
If a webform as fields for user information (address, name, phone,
etc) and a submit button... What is the best way in asp.net to
re-display the information and ask the user to verify the info is
correct.
Will I do a post back to the same webform, remove the previous web
server controls and redraw the page w/ the new information?
Would it be best to transfer to a new page (via Response.Redirect
(url) or Server.Transfer (url)) and get the information from the first
webform?
thanks,
rogerIt's probably easiest to do something like posting the data to a new form
which will display it to the user and ask for confirmation. You could also
write your original page to check for whether this is a postback or not,
and then generate the form's target and the data fields on the fly.
Assuming your page is "page1.aspx" it might be something like:
<some header information>
...
if (isPostBack = true) then
Response.Write("Please confirm the data and hit sumbit again (or some
other message)");
endif
if (isPostBack = true) then
response.write("<form method=post target=page2.aspx");
else
response.write("<form method=post target=page1.aspx");
endif
Then, when writing out your textboxes and other input forms, you can check
to see if ispostback = true and it it is, you can populate the value
appropriately from the request object.
</form
Just a thought,
Chris
-------
>From: roger_beniot@.yahoo.com (roger beniot)
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>Subject: newbie navigation/form re-draw issue...
>Date: 6 Apr 2004 12:12:53 -0700
>Organization: http://groups.google.com
>Lines: 18
>Message-ID: <6c7aa9be.0404061112.30a2134f@.posting.google.com>
>NNTP-Posting-Host: 12.129.11.151
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 8bit
>X-Trace: posting.google.com 1081278773 7573 127.0.0.1 (6 Apr 2004 19:12:53
GMT)
>X-Complaints-To: groups-abuse@.google.com
>NNTP-Posting-Date: Tue, 6 Apr 2004 19:12:53 +0000 (UTC)
>Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.sul.t-online.de!t-onlin
e.de!news.glorb.com!postnews1.google.com!not-for-mail
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:224021
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>I'm trying to figure out how to do something in ASP.NET that used to
>be accomplished by doing a post from one page to another page.
>If a webform as fields for user information (address, name, phone,
>etc) and a submit button... What is the best way in asp.net to
>re-display the information and ask the user to verify the info is
>correct.
>Will I do a post back to the same webform, remove the previous web
>server controls and redraw the page w/ the new information?
>Would it be best to transfer to a new page (via Response.Redirect
>(url) or Server.Transfer (url)) and get the information from the first
>webform?
>
>thanks,
>roger
Friday, March 16, 2012
newbie navigation/form re-draw issue...
be accomplished by doing a post from one page to another page.
If a webform as fields for user information (address, name, phone,
etc) and a submit button... What is the best way in asp.net to
re-display the information and ask the user to verify the info is
correct.
Will I do a post back to the same webform, remove the previous web
server controls and redraw the page w/ the new information?
Would it be best to transfer to a new page (via Response.Redirect
(url) or Server.Transfer (url)) and get the information from the first
webform?
thanks,
rogerIt's probably easiest to do something like posting the data to a new form
which will display it to the user and ask for confirmation. You could also
write your original page to check for whether this is a postback or not,
and then generate the form's target and the data fields on the fly.
Assuming your page is "page1.aspx" it might be something like:
<some header information>
..
if (isPostBack = true) then
Response.Write("Please confirm the data and hit sumbit again (or some
other message)");
endif
if (isPostBack = true) then
response.write("<form method=post target=page2.aspx");
else
response.write("<form method=post target=page1.aspx");
endif
Then, when writing out your textboxes and other input forms, you can check
to see if ispostback = true and it it is, you can populate the value
appropriately from the request object.
</form>
Just a thought,
Chris
--
>From: roger_beniot@.yahoo.com (roger beniot)
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>Subject: newbie navigation/form re-draw issue...
>Date: 6 Apr 2004 12:12:53 -0700
>Organization: http://groups.google.com
>Lines: 18
>Message-ID: <6c7aa9be.0404061112.30a2134f@.posting.google.com>
>NNTP-Posting-Host: 12.129.11.151
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 8bit
>X-Trace: posting.google.com 1081278773 7573 127.0.0.1 (6 Apr 2004 19:12:53
GMT)
>X-Complaints-To: groups-abuse@.google.com
>NNTP-Posting-Date: Tue, 6 Apr 2004 19:12:53 +0000 (UTC)
>Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!news.glorb.com!postnews1.google.com!not-for-mail
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:224021
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>I'm trying to figure out how to do something in ASP.NET that used to
>be accomplished by doing a post from one page to another page.
>If a webform as fields for user information (address, name, phone,
>etc) and a submit button... What is the best way in asp.net to
>re-display the information and ask the user to verify the info is
>correct.
>Will I do a post back to the same webform, remove the previous web
>server controls and redraw the page w/ the new information?
>Would it be best to transfer to a new page (via Response.Redirect
>(url) or Server.Transfer (url)) and get the information from the first
>webform?
>
>thanks,
>roger
>