Showing posts with label form. Show all posts
Showing posts with label form. Show all posts

Thursday, March 29, 2012

Please explain why AddHandler works in Page_Load, but not Butt

Sorry, but I still don't get it. What I have in mind is a form with 3 states
that would look a bit like google. State 1, you see a textbox and button, yo
u
type a search value and press the button, State 2, a list of search results
is displayed (a table with a LinkButton in each row), you click on the
selected row's LinkButton. State 3, The details about the selected item are
displayed along with a button to go back to state 1.
The database search after state 1 and the insertion of the results and
LinkButtons in the table must take place in the Button's Click event, the
table duly appears with the data and LinkButtons. At the end of state 2, the
LinkButtons cause a post, but no event is fired, also the entire contents of
the table no longer exist - this does not matter as I only want to know the
ID of the button.
Is the idea of linking the dynamically created LinkButtons to an event the
wrong approach? Should I be looking at the request.form(0) value? Or is my
whole approach wrong, am I thinking too much along Windows Forms lines?
--
John Austin
"Cowboy (Gregory A. Beamer)" wrote:

> It has to do with the order of events in .NET. By the time you hit button
> events, you have already configured controls. Under "sender", you can find
> out which button was clicked and adjust appropriately in Page_Load. Be
> careful, however, with overloading Page_Load with too much, as you can end
> up with disaster.
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> http://gregorybeamer.spaces.live.com
> ****************************************
*********
> Think outside of the box!
> ****************************************
*********
> "John Austin" <John.Austin@dotnet.itags.org.nospam.nospam> wrote in message
> news:08B9C89B-CB28-41CE-899E-4AF85F704B84@dotnet.itags.org.microsoft.com...
>
>Hi John,
First, I recommend you to use [1] as your starting point to learn ASP.NET.
Though it's written for ASP.NET 1.x, it should get you started.
Since ASP.NET page is stateless, a page class instance and its controls
will need to be created at the server side every time the page is posted
back. See following steps to get an overview of the page life cycle:
1) POST Request is issued by client
2) Page-derived class is created, constructor is invoked
3) IHttpHandler.ProcessRequest is invoked (implemented by Page)
4) Page.Init()
5) Page.CreateChildControls()
6) Server-side control state is restored from POST variables and VIEWSTATE
7) Page.Load()
8) Page.Validate()
9) Server-side control events are fired
10) Page.PreRender()
11) Page.Render()
12) Page.RenderChildren()
13) HTTP Response is issued to client
14) Page.Unload()
15) Instance of Page-derived class is discarded
Each control will have a unique ID, this ID will be used to restore the
state from POST variables and VIEWSTATE (step 6) to the re-created controls
(step 5).
During load (step 7), if the current request is a postback, control
properties are loaded with information recovered from view state and
control state. (See [2] fore more information)
For your dynamically added controls to restore state correctly, you must
make sure the controls are added before the Load event. It's a best
practice to re-create them in Page.Load.
Regarding your issue, the LinkButtons are created in Button's Click event,
they are displayed in the result for the first time since Render is taken
place after that (step 11 and step 9). When the LinkButton is clicked and
caused a postback, the LinkButtons are not re-created, and the POST
variables related to them are lost. You could check the Request.Form for
the field that caused the postback, but there're better way to fulfil your
requirement.
Actually your requirement can be best handled by the Repeater [3] control
and DataBinding:
<asp:Button ID="Button1" runat="server" Text="Button"
OnClick="Button1_Click" />
<br />
<asp:Repeater ID="Repeater1" runat="server"
OnItemCommand="Repeater1_ItemCommand">
<HeaderTemplate>
<ul>
</HeaderTemplate>
<ItemTemplate>
<li>
<asp:LinkButton ID="link1" runat="server" CommandName="Link1"
CommandArgument='<%# Eval("Description") %>' Text='<%# Eval("Name") %>'
></asp:LinkButton>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
protected void Button1_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("Description");
dt.Rows.Add("First", "This is the first item");
dt.Rows.Add("Second", "This is the second item");
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
protected void Repeater1_ItemCommand(object source,
RepeaterCommandEventArgs e)
{
if (e.CommandName == "Link1")
{
Response.Write(e.CommandArgument);
}
}
LinkButton's Click event will be bubbled up to the Repeater and fire
ItemCommand instead. Using the CommandName and CommandArgument, we can
differentiate which LinkButton is clicked.
I hope this could help you get familiar with how ASP.NET works and how to
handle such scenario using appropriate controls. Please feel free to let me
know whether or not you need further information. Thank you.
References:
[1] INFO: ASP.NET Roadmap
http://support.microsoft.com/kb/305140/
[2] ASP.NET Page Life Cycle Overview
http://msdn2.microsoft.com/en-us/library/ms178472.aspx
[3] Repeater Web Server Control Overview
http://msdn2.microsoft.com/en-us/library/x8f2zez5.aspx
Sincerely,
Walter Wang (wawang@.online.microsoft.com, remove 'online.')
Microsoft Online Community Support
========================================
==========
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscript...t/default.aspx.
========================================
==========
This posting is provided "AS IS" with no warranties, and confers no rights.
Thank you Walter for your excellent reply. Whilst checking request.form(0) i
n
Page_Load was a work around (after they click, I don't want the table
anyway), the Repeater is a better solution for me as I can use the event
driven methodology that I am used to with Windows Forms applications.
Thanks once again,
--
John Austin
"Walter Wang [MSFT]" wrote:

> Hi John,
> First, I recommend you to use [1] as your starting point to learn ASP.NET.
> Though it's written for ASP.NET 1.x, it should get you started.
> Since ASP.NET page is stateless, a page class instance and its controls
> will need to be created at the server side every time the page is posted
> back. See following steps to get an overview of the page life cycle:
> 1) POST Request is issued by client
> 2) Page-derived class is created, constructor is invoked
> 3) IHttpHandler.ProcessRequest is invoked (implemented by Page)
> 4) Page.Init()
> 5) Page.CreateChildControls()
> 6) Server-side control state is restored from POST variables and VIEWSTATE
> 7) Page.Load()
> 8) Page.Validate()
> 9) Server-side control events are fired
> 10) Page.PreRender()
> 11) Page.Render()
> 12) Page.RenderChildren()
> 13) HTTP Response is issued to client
> 14) Page.Unload()
> 15) Instance of Page-derived class is discarded
> Each control will have a unique ID, this ID will be used to restore the
> state from POST variables and VIEWSTATE (step 6) to the re-created control
s
> (step 5).
> During load (step 7), if the current request is a postback, control
> properties are loaded with information recovered from view state and
> control state. (See [2] fore more information)
> For your dynamically added controls to restore state correctly, you must
> make sure the controls are added before the Load event. It's a best
> practice to re-create them in Page.Load.
> Regarding your issue, the LinkButtons are created in Button's Click event,
> they are displayed in the result for the first time since Render is taken
> place after that (step 11 and step 9). When the LinkButton is clicked and
> caused a postback, the LinkButtons are not re-created, and the POST
> variables related to them are lost. You could check the Request.Form for
> the field that caused the postback, but there're better way to fulfil your
> requirement.
> Actually your requirement can be best handled by the Repeater [3] control
> and DataBinding:
>
> <asp:Button ID="Button1" runat="server" Text="Button"
> OnClick="Button1_Click" />
> <br />
> <asp:Repeater ID="Repeater1" runat="server"
> OnItemCommand="Repeater1_ItemCommand">
> <HeaderTemplate>
> <ul>
> </HeaderTemplate>
> <ItemTemplate>
> <li>
> <asp:LinkButton ID="link1" runat="server" CommandName="Link1"
> CommandArgument='<%# Eval("Description") %>' Text='<%# Eval("Name") %>'
> </li>
> </ItemTemplate>
> <FooterTemplate>
> </ul>
> </FooterTemplate>
> </asp:Repeater>
>
> protected void Button1_Click(object sender, EventArgs e)
> {
> DataTable dt = new DataTable();
> dt.Columns.Add("Name");
> dt.Columns.Add("Description");
> dt.Rows.Add("First", "This is the first item");
> dt.Rows.Add("Second", "This is the second item");
> Repeater1.DataSource = dt;
> Repeater1.DataBind();
> }
> protected void Repeater1_ItemCommand(object source,
> RepeaterCommandEventArgs e)
> {
> if (e.CommandName == "Link1")
> {
> Response.Write(e.CommandArgument);
> }
> }
> LinkButton's Click event will be bubbled up to the Repeater and fire
> ItemCommand instead. Using the CommandName and CommandArgument, we can
> differentiate which LinkButton is clicked.
> I hope this could help you get familiar with how ASP.NET works and how to
> handle such scenario using appropriate controls. Please feel free to let m
e
> know whether or not you need further information. Thank you.
> References:
> [1] INFO: ASP.NET Roadmap
> http://support.microsoft.com/kb/305140/
> [2] ASP.NET Page Life Cycle Overview
> http://msdn2.microsoft.com/en-us/library/ms178472.aspx
> [3] Repeater Web Server Control Overview
> http://msdn2.microsoft.com/en-us/library/x8f2zez5.aspx
> Sincerely,
> Walter Wang (wawang@.online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
> ========================================
==========
> Get notification to my posts through email? Please refer to
> [url]http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif[/ur
l]
> ications. If you are using Outlook Express, please make sure you clear the
> check box "Tools/Options/Read: Get 300 headers at a time" to see your repl
y
> promptly.
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscript...t/default.aspx.
> ========================================
==========
> This posting is provided "AS IS" with no warranties, and confers no rights
.
>
Hello Walter,
The Data Repeater works fine, but thinking further about the issue, it would
make sense for state 1 to build a query string from input criteria and store
the select statement in viewstate so that the Page_Load in state 2 can query
the database and generate results (this means that pressing Back in the
browser from state 3 would re-query the database and include any changes).
This would also avoid my original problem; but when in state 1, the button
press would need to build the query string, change the state to 2 and then
force a reload of the current page. How could I force the page to be re-buil
d
from the Button_Click event?
John Austin
"Walter Wang [MSFT]" wrote:

> Hi John,
> First, I recommend you to use [1] as your starting point to learn ASP.NET.
> Though it's written for ASP.NET 1.x, it should get you started.
> Since ASP.NET page is stateless, a page class instance and its controls
> will need to be created at the server side every time the page is posted
> back. See following steps to get an overview of the page life cycle:
> 1) POST Request is issued by client
> 2) Page-derived class is created, constructor is invoked
> 3) IHttpHandler.ProcessRequest is invoked (implemented by Page)
> 4) Page.Init()
> 5) Page.CreateChildControls()
> 6) Server-side control state is restored from POST variables and VIEWSTATE
> 7) Page.Load()
> 8) Page.Validate()
> 9) Server-side control events are fired
> 10) Page.PreRender()
> 11) Page.Render()
> 12) Page.RenderChildren()
> 13) HTTP Response is issued to client
> 14) Page.Unload()
> 15) Instance of Page-derived class is discarded
> Each control will have a unique ID, this ID will be used to restore the
> state from POST variables and VIEWSTATE (step 6) to the re-created control
s
> (step 5).
> During load (step 7), if the current request is a postback, control
> properties are loaded with information recovered from view state and
> control state. (See [2] fore more information)
> For your dynamically added controls to restore state correctly, you must
> make sure the controls are added before the Load event. It's a best
> practice to re-create them in Page.Load.
> Regarding your issue, the LinkButtons are created in Button's Click event,
> they are displayed in the result for the first time since Render is taken
> place after that (step 11 and step 9). When the LinkButton is clicked and
> caused a postback, the LinkButtons are not re-created, and the POST
> variables related to them are lost. You could check the Request.Form for
> the field that caused the postback, but there're better way to fulfil your
> requirement.
> Actually your requirement can be best handled by the Repeater [3] control
> and DataBinding:
>
> <asp:Button ID="Button1" runat="server" Text="Button"
> OnClick="Button1_Click" />
> <br />
> <asp:Repeater ID="Repeater1" runat="server"
> OnItemCommand="Repeater1_ItemCommand">
> <HeaderTemplate>
> <ul>
> </HeaderTemplate>
> <ItemTemplate>
> <li>
> <asp:LinkButton ID="link1" runat="server" CommandName="Link1"
> CommandArgument='<%# Eval("Description") %>' Text='<%# Eval("Name") %>'
> </li>
> </ItemTemplate>
> <FooterTemplate>
> </ul>
> </FooterTemplate>
> </asp:Repeater>
>
> protected void Button1_Click(object sender, EventArgs e)
> {
> DataTable dt = new DataTable();
> dt.Columns.Add("Name");
> dt.Columns.Add("Description");
> dt.Rows.Add("First", "This is the first item");
> dt.Rows.Add("Second", "This is the second item");
> Repeater1.DataSource = dt;
> Repeater1.DataBind();
> }
> protected void Repeater1_ItemCommand(object source,
> RepeaterCommandEventArgs e)
> {
> if (e.CommandName == "Link1")
> {
> Response.Write(e.CommandArgument);
> }
> }
> LinkButton's Click event will be bubbled up to the Repeater and fire
> ItemCommand instead. Using the CommandName and CommandArgument, we can
> differentiate which LinkButton is clicked.
> I hope this could help you get familiar with how ASP.NET works and how to
> handle such scenario using appropriate controls. Please feel free to let m
e
> know whether or not you need further information. Thank you.
> References:
> [1] INFO: ASP.NET Roadmap
> http://support.microsoft.com/kb/305140/
> [2] ASP.NET Page Life Cycle Overview
> http://msdn2.microsoft.com/en-us/library/ms178472.aspx
> [3] Repeater Web Server Control Overview
> http://msdn2.microsoft.com/en-us/library/x8f2zez5.aspx
> Sincerely,
> Walter Wang (wawang@.online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
> ========================================
==========
> Get notification to my posts through email? Please refer to
> [url]http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif[/ur
l]
> ications. If you are using Outlook Express, please make sure you clear the
> check box "Tools/Options/Read: Get 300 headers at a time" to see your repl
y
> promptly.
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscript...t/default.aspx.
> ========================================
==========
> This posting is provided "AS IS" with no warranties, and confers no rights
.
>
Hi John,
See if following code answers your question:
protected void Page_Load(object sender, EventArgs e)
{
RebindData();
}
protected void Button1_Click(object sender, EventArgs e)
{
QueryStatement = "foo sql statement";
RebindData();
}
void RebindData()
{
string sql = QueryStatement;
if (string.IsNullOrEmpty(sql))
{
Repeater1.DataSource = null;
}
else
{
// you need to do sql query in real app; here I'm just
returning a DataTable for test purpose
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("Description");
dt.Rows.Add("First", "This is the first item");
dt.Rows.Add("Second", "This is the second item");
Repeater1.DataSource = dt;
}
Repeater1.DataBind();
}
string QueryStatement
{
get { reutrn ViewState["QueryStatement"] as string; }
set { ViewState["QueryStatement"] = value; }
}
protected void Repeater1_ItemCommand(object source,
RepeaterCommandEventArgs e)
{
if (e.CommandName == "Link1")
{
Response.Write(e.CommandArgument);
}
}
Regards,
Walter Wang (wawang@.online.microsoft.com, remove 'online.')
Microsoft Online Community Support
========================================
==========
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
==========
This posting is provided "AS IS" with no warranties, and confers no rights.
Sorry Walter, putting the creation of the results table in a subroutine is a
far simpler solution - I guess that getting my head round the way web app
work clouded the brain!
Many thanks,
John Austin
"Walter Wang [MSFT]" wrote:

> Hi John,
> See if following code answers your question:
> protected void Page_Load(object sender, EventArgs e)
> {
> RebindData();
> }
> protected void Button1_Click(object sender, EventArgs e)
> {
> QueryStatement = "foo sql statement";
> RebindData();
> }
> void RebindData()
> {
> string sql = QueryStatement;
> if (string.IsNullOrEmpty(sql))
> {
> Repeater1.DataSource = null;
> }
> else
> {
> // you need to do sql query in real app; here I'm just
> returning a DataTable for test purpose
> DataTable dt = new DataTable();
> dt.Columns.Add("Name");
> dt.Columns.Add("Description");
> dt.Rows.Add("First", "This is the first item");
> dt.Rows.Add("Second", "This is the second item");
> Repeater1.DataSource = dt;
> }
> Repeater1.DataBind();
> }
> string QueryStatement
> {
> get { reutrn ViewState["QueryStatement"] as string; }
> set { ViewState["QueryStatement"] = value; }
> }
> protected void Repeater1_ItemCommand(object source,
> RepeaterCommandEventArgs e)
> {
> if (e.CommandName == "Link1")
> {
> Response.Write(e.CommandArgument);
> }
> }
> Regards,
> Walter Wang (wawang@.online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
> ========================================
==========
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ========================================
==========
> This posting is provided "AS IS" with no warranties, and confers no rights
.
>

Please Fix Form Post in Whidbey

I used to have forms like this that would post the information to the next website (listed in Action). This simple task has become onerous in VS.NET. Please please come up with a simple correction for this! Maybe a new control or something? I've seen some commercial controls attempt to use server transfer (not quite what I wanted). I've also tried doing it myself, but the next page will never display and it needs to because it has the result in HTML format! Come on...this was a 5 second deal in HTML and weeks in ASP.NET!!!!

<form method=post action="https://website">
<font size=+1>Special Order</font><br>
<input type=hidden name="PartNo" value="S-001">
<input type=hidden name="Item" value="Special Order">
Price: $<input type=text name="Price" value="0" size=10>
<input type=hidden name="Price" value="m-Price;10">
... and so on

</form>You can now in Whidbey add a PostTargetUrl attribute to the buttons control. When you press a button that has the PostTargetUrl attribute specified, the page will post the data to the specified target.

<asp:Button … PostTargetUrl="MyPage.aspx" …>
There are several ways to post to other urls in v1.* today:
(1) Use regular <form> tag, without any runat=server attribute or controls.
(2) Use javascript to change the server form's action attribute on the fly.
(3) MetaBuilders.com has a free custom server form with action enabled.
(4) My WilsonWebForm enables both action and multiple server forms.

Monday, March 26, 2012

Please help

Hello I have created a login page using the login page form. After a user logs in I re-direct the user to the protected page by using the following

FormsAuthentication.RedirectFromLoginPage(UserName.selecteditem.value, true). The user is then redirected to a new page default.aspx. On this page I want unique information related to this users username. How do I do this ? EG it should display only accounts related to this user from the accounts database. How do I pass the username from the Login page to this page? or should I get it from the cookies? If so how?Just need to know how to get the login name from Login.aspx to default.aspx

Thanks

GrantHave you treid giving
Response.Write(user.Identity.Name)?
Test.
Hi!

I would like to know where should one give the Response.Write(user.Identity.Name)?

in the login.aspx or default.aspx file. As it does not work for me both ways.

Thanks
Do you have

 <identity impersonate="true" />
line in your web.config
try giving this and check if you get user name
Hi Sushila,

Thanks for your quick response. I was unable to execute the program and get a runtime error. This stops me from doing anything.

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File --
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration
Your help will be appreciated.

Thanks

Sukumar
Are you enclosing this tag within


<system.web>
.....
<identity impersonate="true" />
</system.web>

Even without giving this tag <identity impersonate="true" /> User.Identity.Name works

SuKumar : can u paste the error that is shows when u give
Response.Write(User.Identity.Name)

Saturday, March 24, 2012

Please help = Im desparate

I come from a PHP background and I'm having a heck of a time solving this problem. I need to create a contact form/ shopping cart. The form will consist of:

1. Product info(orderForm.asp):
the customer will select products and the a form for personal info will be filled out - this will include name. address, credit cart info, etc

2. Confirm order (orderConfirm.asp):
the values of the customers products will be added up and sent to this page along with the info previousley filled in and the order is sent by encrypted email.

I have done this with PHP by declaring variables and using 'if then else' statements.

Anybody have any idea how I can achieve this. It has to be done yesterday

I am not sure what exactly you need here.

If you would like to know about sending mails from ASP.net, check this link (its explined with an example)

http://www.developer.com/net/asp/article.php/3096831


kevinritt:

I come from a PHP background and I'm having a heck of a time solving this problem. I need to create a contact form/ shopping cart. The form will consist of:

1. Product info(orderForm.asp):
the customer will select products and the a form for personal info will be filled out - this will include name. address, credit cart info, etc

2. Confirm order (orderConfirm.asp):
the values of the customers products will be added up and sent to this page along with the info previousley filled in and the order is sent by encrypted email.

I have done this with PHP by declaring variables and using 'if then else' statements.

Anybody have any idea how I can achieve this. It has to be done yesterday

kevinritt --

Check out these links...

ASP.NET Getting Started -- http://www.asp.net/getstarted/default.aspx?tabid=61

ASP.NET Quick Start Tutorials --http://quickstarts.asp.net/QuickStartv20/aspnet/Default.aspx

Learn ASP.NET --http://www.asp.net/learn/default.aspx?tabid=63

ASP.NET Starter Kits --http://www.asp.net/downloads/starterkits/default.aspx?tabid=62

One quick way to get your project done is to setup one of the eCommerce Starter Kit applications and then make it suit your needs. However, those are complex applications and may be beyond your level right now. If that is the case, then just study them a bit. Maybe.

In short, what you need is a web-application, 2 pages, and a database. You need (1) allow the user to enter data on Form1. (2) when the user submits the data on Form1, you will grab the data programmatically and put it in the database and then redirect to Form2; (3) on Form2, you will get the data from the database, put it on Form2, and show the email to be sent; (4) when the user submits Form2 you will send the data in the email.

That's some work, no doubt about it. You will need to know how to do (A) database access, (B) email sending, (C) navigation, and (D) page layout. Your best bet, I think, is to go through the QuickStarts and find the sections for A, B, C, and D, learn them, and then try to code it.

(A) Data Access --http://quickstarts.asp.net/QuickStartv20/aspnet/doc/data/default.aspx

(C) Navigation and (D) Page Layout --http://quickstarts.asp.net/QuickStartv20/aspnet/doc/pages/default.aspx

(B) Email --http://www.developer.com/net/asp/article.php/3096831 orhttp://aspalliance.com/149_How_to_Send_Email_from_ASP_NET_

Is this is your 1st application, then it will take some time to get over the initial learning curve. However, after this application is done, I think you will see the power of ASP.NET over Classic ASP and PHP. IMHO.

HTH.

Thank you.

-- Mark Kamoski

Wednesday, March 21, 2012

Please Help me

i,m abdusalam :ehh:
i want passed parameter form site to another site to access to some data
throuth submit this parameters in textbox
please dont forget meplease dont forget me

Who are you?!

In the button click event, take the values from the textbox and append them to the querystring for your other site, assuming it does take querystrings.

newsite.com/pagename.aspx?param1=value1¶m2=value2

Please help label text problem

i am new to ASP.net
i am making a form where der are 3 labels
EG. First name
Last name
Password

which have 3 textbox too.. now in labels the text i want it in extreme right.. like in vb.net we have textAlign right, left, center.. Rite

I want to do same in ASP.net i was looking in properties der is nothing like textalign. i tried to write <center> Firstname </center> in the html code(ASP.Net) but code dint work out.. please help me..If you are using an ASP.NET label, just move it to the desired position.
You need to look at an HTML tutorial, you should use DIVs and TABLEs to align your elements as you want.

www.w3schools.com/html
Good point, you should try using DIV's and inserting the desired text, that way you can justify it to the left, center, or right if you want.

Please help me create a simple page

Today i was creating my first page in asp.net and the very soon i realized that
microsoft products were not trustworthy i created a simple web form
with two text boxes and two labels/one label but when i created the solution
(build solution) see what is the IE displaying me in second screen shot

designed a simple login form

http://img171.imageshack.us/img171/6276/form1ts2.jpg

this is what it gave me as an output no web tools being displayed only one label i cant see the text box or any submit button i have seen the html code thats generated and its fine

http://img105.imageshack.us/img105/65/iepageid3.jpg

I am using Visual studio 2002 version and IIS v 5.1 no antivirus is running and
default website has been granted permission

can anyone please please help me out :) thankstry recompiling your project and then refreshing IE after you do so.

If there is still no change, then I suggest you uninstall zone alarm.

I had an issue with VS 2003 where zone alarm broke asp.net
Disabling it did't fix my issue, but when I fully uninstalled it, asp.net was working again.
thanks 4 the help buddy
no success now i need to reinstall zone alarm any more ideas do you think
i need to reinstall visual studio all over again because all other .aspx files i downloaded from net are running fine on IIS so IIS is problem free

ok its 1:09 night and i need a nap when i wake up I hope some good
person will surely help me out thanks

ASP.net took away this night :cry:
Well, the problem could be anything!!

Check in the HTML part that the <form> tag is present. Or check the visibility properties of the non-rendered controls.

Or just upload the project!!
you may also want to look into upgrading to using the 2.0 framework.

You can get a Visual Studio Web Developer Express for free here
http://msdn.microsoft.com/vstudio/express/vwd/

and this is very very similar to ASP.NET in VS 2002, except they improved a LOT of the things that were problems in the previous versions..

Visual Studio .NET 2002 was almost more of a beta for .NET than a full on programming language, most people moved quickly to 1.1 (2003) when that came out, and then to 2.0 (2005)

The fact that Microsoft gives you the express tools for free, makes it easier to upgrade to the newer version, because you don't have to shell out money for a good IDE.
thanks guys i think i need to reinstall the asp.net now but the problem with 2005 express version is that there is no

sqlconnection and oledbconnection object tool in the data tab of the toolbox
so i was not using it :wave:
http://msdn2.microsoft.com/en-us/library/k6h9cz8h(VS.80).aspx

Run the aspnet_regiis tool. Your files don't seem to have 'registered' properly.

aspnet_regiis /i

Please help me to create button search...

plss,...i am very new in asp.net..?can someone help me how to create button search in form including coding can be search in ms access....::((Hello, have a look at the following, they might give you an idea on how to process:
1-Populating a Search Engine with a C# Spider
2-Internal Site Search Engine
Regards

Friday, March 16, 2012

please help me understand! ASP.Net - VB.NET

ok, so i took this sample form a site that offered to take the source code for the perpose of learning so i did. except that it is not working on my machine but its running where i got it from (the site).
could you please assist me knowing where the code went wrong?
the code is listed below:
<%@dotnet.itags.org. Page Language="VB" ClientTarget="downlevel" %>
<%@dotnet.itags.org. Import Namespace="System.Web.Mail" %>

<script language="VB" runat="server">
Sub btnSendMail_OnClick(Source As Object, E As EventArgs)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
Dim strEmail As String

If Page.IsValid() Then
strEmail = txtEmail.Text

myMessage.From = "webmaster@dotnet.itags.org." & Request.ServerVariables("SERVER_NAME")
myMessage.To = strEmail
myMessage.Subject = "E-mail Sample from ASP 101!"
myMessage.Body = "This message was sent from sample code by " & _
"http://www.asp101.com. It is used to show people how " & _
"to send e-mail from an ASP+ page. This mail was sent " & _
"from " & Request.ServerVariables("SERVER_NAME") & ". " & _
vbCrLf & vbCrLf & _
"This email was sent to " & strEmail & "."

' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "localhost"
myMail.Send(myMessage)

frmEmail.Visible = False
lblUserMessage.Text = "Your message has been sent to " & strEmail & "."
End If
End Sub
</script>

<html>
<head>
<title>ASP+ Email Sample</title>
</head>
<body>

<asp:Label id="lblUserMessage" text="Enter your e-mail address:" runat="server" />
<form method="post" id="frmEmail" runat="server">
<asp:TextBox id="txtEmail" size="30" runat="server" />
<asp:RequiredFieldValidator runat="server"
id="validEmailRequired" ControlToValidate="txtEmail"
errormessage="Please enter an email address."
display="Dynamic" />
<asp:RegularExpressionValidator runat="server"
id="validEmailRegExp" ControlToValidate="txtEmail"
ValidationExpression="^[\w-]+@dotnet.itags.org.[\w-]+\.(com|net|org|edu|mil)$"
errormessage="Please enter a valid email address."
Display="Dynamic" />

<asp:Button id="btnSendMail" text="Send Mail!" OnClick="btnSendMail_OnClick" runat="server" />
</form>

</body>
</html>

Thanks,
Rami Wahdan.

Hello,

I'm beginner also, but what I would try is:

Change line:
myMessage.From = "webmaster@." & Request.ServerVariables("SERVER_NAME")

into:
myMessage.From = "your@.email.com"

and delete these lines:
' Doesn't have to be local... just enter your
' SMTP server's name or ip address!
myMail.SmtpServer = "localhost"


Rami,

it would also help if you would paste the exact error you are getting ... that will help in identifying your problem ...

cheers,

erik


ok so the error is:

Server Error in '/ASP.NET/email' Application.

The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for a@.a.com

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:System.Runtime.InteropServices.COMException: The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for a@.a.com
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@. Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.

Stack Trace:
[COMException (0x8004020f): The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for a@.a.com][TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0 System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) +1966108 System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +56[HttpException (0x80004005): The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for a@.a.com] System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +105 System.Web.Mail.CdoSysHelper.Send(MailMessage message) +3632 System.Web.Mail.SmtpMail.Send(MailMessage message) +102 System.Web.Mail.SmtpMail.Send(MailMessage message) +0 ASP.email_aspx.btnSendMail_OnClick(Object Source, EventArgs E) +325 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +232 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +5 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +31 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5157


Version Information: Microsoft .NET Framework Version:2.0.40607.16; ASP.NET Version:2.0.40607.16

hmm, the error seems rather clear, what exactly did you do to solve it?
>The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for a@.a.com
this means that the address you are sending to (a@.a.com) does not exist ...
to prevent this error to cause this page to display, you could add a Try ... Catch ... End Try statement around myMail.send(myMessage), like this:
Try
myMail.Send(myMessage)
Catch ex as Exception
End Try
Mind you, this only prevents the application to stop on the error, you should add code to handle the error properly
HTH
cheers,
erik

Please help me with this simple line of code.

Hello,
i am creating an ASP.net / VB web site with Dreamweaver MX 2004.
I have a form and a "Insert Record Behavior" to insert the form values in
the database.
Dreamweaver puts this code in the end of the form:
..
<input type="hidden" name="MM_insert" value="myForm"> (1)
</form>
The form is in a Multipanel. So when i first click the "Next" button the
form values are inserted in the database.
I want the form values to be inserted in the database only when the "Finish"
button is pressed.
I have the code which detects when the "Finish" button is pressed. All i
need is to know how to give the order not in (1) but inside the following
code:
Sub btnFinish_Click( s As Object, e As EventArgs )
End Sub
I am on this since today morning but until know i have no idea of how to do
this. Please help me. I tryied and looked for every options.
Thank You,
MiguelI believe what you are asking is "how do I code for inserting a record when
the finish button is clicked"...is that about right?
If this is what you are asking, you have not provided enough information, su
ch as what is the source file you are wanting to update.
You will need a Connection Object, which typically come in 3 flavors (ODBC,
OLEDB, or SQL)
You will need a connection string to properly build your command object. Th
ere are places on the web which provided examples of connection strings to t
he 3 flavors noted above. Seach on ConnectionString or OLEDB Connections
You will need a command Object, again, these come in the same 3 flavors.
To properly build the Command ogject, you will need to Connection Object dis
cussed above and your query - Something line "Insert into MyDatabaseName Val
ues( MyValue1,...MyLastValue) .
Once you have all of that in-place, you will then need to open the connectio
n.
Then you will use the "ExecuteNonQuery" method of the command object, which
will invoke your query.
If you have never created a connection to your database/file or every writte
n a query, you have a lot of studying to do.

Please help me with this simple line of code.

Hello,

i am creating an ASP.net / VB web site with Dreamweaver MX 2004.

I have a form and a "Insert Record Behavior" to insert the form values in
the database.

Dreamweaver puts this code in the end of the form:
...
<input type="hidden" name="MM_insert" value="myForm"> (1)
</form
The form is in a Multipanel. So when i first click the "Next" button the
form values are inserted in the database.
I want the form values to be inserted in the database only when the "Finish"
button is pressed.

I have the code which detects when the "Finish" button is pressed. All i
need is to know how to give the order not in (1) but inside the following
code:

Sub btnFinish_Click( s As Object, e As EventArgs )
>> I want to give the order here.
End Sub

I am on this since today morning but until know i have no idea of how to do
this. Please help me. I tryied and looked for every options.

Thank You,
MiguelI believe what you are asking is "how do I code for inserting a record when the finish button is clicked"...is that about right?
If this is what you are asking, you have not provided enough information, such as what is the source file you are wanting to update.

You will need a Connection Object, which typically come in 3 flavors (ODBC, OLEDB, or SQL)
You will need a connection string to properly build your command object. There are places on the web which provided examples of connection strings to the 3 flavors noted above. Seach on ConnectionString or OLEDB Connections
You will need a command Object, again, these come in the same 3 flavors.
To properly build the Command ogject, you will need to Connection Object discussed above and your query - Something line "Insert into MyDatabaseName Values( MyValue1,...MyLastValue) .
Once you have all of that in-place, you will then need to open the connection.
Then you will use the "ExecuteNonQuery" method of the command object, which will invoke your query.

If you have never created a connection to your database/file or every written a query, you have a lot of studying to do.

Please help me, and close the darn form!

Hi,
I've been here before and i'm still stuck with the same problem. I just can't close the stupid form.
I'm using microsoft's browser control on my aplication. I can open a new form when i click any link. That works great.

The BIG problem is when the javascript:window.close() is called from any page. The browser control closes, but i get stuck with the form it was on. I just can't close it.

Please help me. I've been to all kind of forums and still haven't found a solution.

Thanks.I think it has something to do with this bug. It looks like the WindowClosing event isn't beeing fired.

Can someone translate this into VB.Net.

http://www.codeproject.com/buglist/iefix.asp

Thanks.
I've never used the WebBrowser control, so I can't help there.

However, here is an onlineC# to VB.NET converter. It will convert the code provided in the article you referenced.

Hope this helps.
I got it. Thanks for your post "SomeNewKid2", but i didn't use that code. To confusing.

I was trying to use the windowclosing event and it didn't work. I found out that it work with the leave handler.
Like this:


Private Sub AxWebBrowser1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxWebBrowser1.Leave
Me.Close()
End Sub

This closes the stupid form also.
Stay well.