473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

.Net AutoPostBack issue

Hello,

I am still a little new to the .net environment and trying to learn
some of its features and functions.
I have a page with creates some dynamic controls on page load once a
user has selected the number of dynamc controls to be created. It
could be anywhere from 1 - 10. This happens with no problem. The
problem I am having is trying to refer to those controls text
property. I have a button that is going to save the values into a
table. But each time I type something in a dynamic textbox or select
a
value from the dynamic dropdown, the page is reloaded and I lose the
selected and/or entered values.
Is there a way I can avoid the page to reload when I click the button
and force it under certain conditions? This I believe may be hard but
then do I have other options?
I would appreciate any help I can get on this.
Thanks in advance.
Anil
Nov 16 '07 #1
3 1189
LionsDome wrote:
Hello,

I am still a little new to the .net environment and trying to learn
some of its features and functions.
I have a page with creates some dynamic controls on page load once a
user has selected the number of dynamc controls to be created. It
could be anywhere from 1 - 10. This happens with no problem. The
problem I am having is trying to refer to those controls text
property. I have a button that is going to save the values into a
table. But each time I type something in a dynamic textbox or select
a
value from the dynamic dropdown, the page is reloaded and I lose the
selected and/or entered values.
Is there a way I can avoid the page to reload when I click the button
and force it under certain conditions? This I believe may be hard but
then do I have other options?
I would appreciate any help I can get on this.
Thanks in advance.
Anil

If you need create dynamic web control in web page, you should create
them in page's Init event. Because every control in web page is created
at this event, you can see more information at
http://msdn2.microsoft.com/en-us/library/ms972976.aspx

For example:

protected void Page_Init(object sender, EventArgs e)
{
Button btn = new Button();
Label lbl = new Label();
Literal text = new Literal();
text.Text = "<br />";
lbl.Text = "You not click";
btn.Text = "Click me";
btn.Click += delegate { lbl.Text = "Hi, you clicked"; };
this.Controls.Add(btn);
this.Controls.Add(text);
this.Controls.Add(lbl);
}
May be you should use PlaceHolder control to contain your dynamic controls.

--
Duy Lam Phuong
Nov 17 '07 #2
On Nov 17, 10:42 am, Duy Lam <duylamphu...@gmail.comwrote:
LionsDome wrote:
Hello,
I am still a little new to the .netenvironment and trying to learn
some of its features and functions.
I have a page with creates some dynamic controls on page load once a
user has selected the number of dynamc controls to be created. It
could be anywhere from 1 - 10. This happens with no problem. The
problem I am having is trying to refer to those controls text
property. I have a button that is going to save the values into a
table. But each time I type something in a dynamic textbox or select
a
value from the dynamic dropdown, the page is reloaded and I lose the
selected and/or entered values.
Is there a way I can avoid the page to reload when I click the button
and force it under certain conditions? This I believe may be hard but
then do I have other options?
I would appreciate any help I can get on this.
Thanks in advance.
Anil

If you need create dynamic web control in web page, you should create
them in page's Init event. Because every control in web page is created
at this event, you can see more information athttp://msdn2.microsoft.com/en-us/library/ms972976.aspx

For example:

protected void Page_Init(object sender, EventArgs e)
{
Button btn = new Button();
Label lbl = new Label();
Literal text = new Literal();
text.Text = "<br />";
lbl.Text = "You not click";
btn.Text = "Click me";
btn.Click += delegate { lbl.Text = "Hi, you clicked"; };
this.Controls.Add(btn);
this.Controls.Add(text);
this.Controls.Add(lbl);
}

May be you should use PlaceHolder control to contain your dynamic controls.

--
Duy Lam Phuong- Hide quoted text -

- Show quoted text -

Hello Duy Lam,

Thanks for the response. I do have a place holder that contain my
dynamic controls. But I guess I am not yet clear on how it will help
my in trying to make a reference to my controls in there. I cannot use
the page init event because the dynamic controls will only be created
once user selects from the dropdown. Should I be trying to do this
another way? I rather not given the time and effort I have spend so
far on creating this. Can give you perhaps give me a syntax or
something that will allow me to refer to the dynamic controls in the
placeholder?

Thanks.

Anil
Nov 20 '07 #3
On Nov 17, 1:40 am, LionsDome <AKhemchand...@gmail.comwrote:
Hello,

I am still a little new to the .net environment and trying to learn
some of its features and functions.

I have a page with creates some dynamic controls on page load once a
user has selected the number of dynamc controls to be created. It
could be anywhere from 1 - 10. This happens with no problem. The
problem I am having is trying to refer to those controls text
property. I have a button that is going to save the values into a
table. But each time I type something in a dynamic textbox or select
a
value from the dynamic dropdown, the page is reloaded and I lose the
selected and/or entered values.

Is there a way I can avoid the page to reload when I click the button
and force it under certain conditions? This I believe may be hard but
then do I have other options?

I would appreciate any help I can get on this.

Thanks in advance.

Anil
hi
anil,this is vijay
when you want to mantain controls data , you need to set viewstate
property =enabled/true in .aspx file .
you can set in three lelevels
page level it will enabled for enter page
control level this is for single mor controls set view state property
to to enabled/true

Nov 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: KathyB | last post by:
Hi, clearly I'm just not getting something here. I have an aspx form with ONE textbox and several label controls on it. I have the textbox set to AutoPostBack = True, but when I enter my text...
8
by: Matthew Louden | last post by:
why need to set autopostback property to be true?? I know autopostback event means to send the form to the server automatically. I tried checkbox, checkbox list, radio button, and radio button...
1
by: Pete Davis | last post by:
First of all, I'm more or less a novice at web stuff, not just ASP.NET but JavaScript and VBScript as well. I've got a page for doing reservations for a hotel. They want to do two things that...
1
by: Mad Scientist Jr | last post by:
I'm having this issue where textbox A on my form is recalculated every time textbox B, C, or D is changed. To complicate this, if dropdown D = 1, for example, A = B + C, if dropdown D = 2, A = C *...
7
by: Ron | last post by:
Hello all, I don't understand why my pageis not posting back to the server when I change the selection on a radio list. I have a page that both accepts new personal info. or allows editing to...
2
by: rdb | last post by:
VB.NET web program with a webform w/2 dropdownlistboxes, set to AutoPostBack TRUE, selection in either dropdown fires the SelectedIndexChanged events correctly UNTIL I navigate to second webform in...
2
by: Sean Chapman | last post by:
I've got a simple page I've made with a few controls (Treeview, Dropdownlist, ..). I'm running into an issue with autopostback. If I set it to AutoPostBack = "True", when the event should fire I...
1
by: Sean Chapman | last post by:
I've got a simple page I've made with a few controls (Treeview, Dropdownlist, ..). I'm running into an issue with autopostback. If I set it to AutoPostBack = "True", when the event should fire I...
3
by: Brad | last post by:
The first text on my form is a numeric field. I have a javascript that runs on this field for onkeyup (validate the key strokes and modifies fields on the screen) but when I do this and have the...
2
by: rn5a | last post by:
Assume that a user control has a TextBox (Page1.ascx) <asp:TextBox ID="txtName" runat="server"/> I am encapsulating the above user control in a ASPX page named Page1.aspx i.e. the ASPX page...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.