Showing posts with label behavior. Show all posts
Showing posts with label behavior. Show all posts

Thursday, March 29, 2012

Please explain strange viewstate behavior...

I am dynamically adding an HtmlInputHidden element with different values.
The problem is the first time I add it with a given value and submit it then
change the value within the Page_Load event it still has the original value.
I am guessing this has something to do with viewstate. I have turned off
viewstate at the page level, but the issue still occurs. Any suggestions?
The code is basic:
HtmlInputHidden phihAction = new HtmlInputHidden();
phihAction.ID = "hdnAction";
phihAction.Value = ((short)pactAction).ToString();
mfrmUser.Controls.Add( phihAction );
pactAction is an enumeration that changes based on action (i.e. 1=Add, 2=Edi
t)
Any help in understanding why it does what it does and how to work around it
would be greatly appreciated.
RobertRobert,
You need to check IsPostBack property befory assigning the value:
HtmlInputHidden phihAction = new HtmlInputHidden();
phihAction.ID = "hdnAction";
if (IsPostBack)
phihAction.Value = ((short)pactAction).ToString();
mfrmUser.Controls.Add( phihAction );
Eliyahu
"rgrandidier" <rgrandidier@.discussions.microsoft.com> wrote in message
news:E0B96D78-C2B6-4A46-BE08-E7E7B7FD1893@.microsoft.com...
> I am dynamically adding an HtmlInputHidden element with different values.
> The problem is the first time I add it with a given value and submit it
then
> change the value within the Page_Load event it still has the original
value.
> I am guessing this has something to do with viewstate. I have turned off
> viewstate at the page level, but the issue still occurs. Any suggestions?
> The code is basic:
> HtmlInputHidden phihAction = new HtmlInputHidden();
> phihAction.ID = "hdnAction";
> phihAction.Value = ((short)pactAction).ToString();
> mfrmUser.Controls.Add( phihAction );
> pactAction is an enumeration that changes based on action (i.e. 1=Add,
2=Edit)
> Any help in understanding why it does what it does and how to work around
it
> would be greatly appreciated.
> --
> Robert

Please explain strange viewstate behavior...

I am dynamically adding an HtmlInputHidden element with different values.
The problem is the first time I add it with a given value and submit it then
change the value within the Page_Load event it still has the original value.
I am guessing this has something to do with viewstate. I have turned off
viewstate at the page level, but the issue still occurs. Any suggestions?

The code is basic:
HtmlInputHiddenphihAction = new HtmlInputHidden();

phihAction.ID = "hdnAction";
phihAction.Value = ((short)pactAction).ToString();
mfrmUser.Controls.Add( phihAction );

pactAction is an enumeration that changes based on action (i.e. 1=Add, 2=Edit)

Any help in understanding why it does what it does and how to work around it
would be greatly appreciated.

--
RobertRobert,

You need to check IsPostBack property befory assigning the value:

HtmlInputHidden phihAction = new HtmlInputHidden();

phihAction.ID = "hdnAction";
if (IsPostBack)
phihAction.Value = ((short)pactAction).ToString();
mfrmUser.Controls.Add( phihAction );

Eliyahu

"rgrandidier" <rgrandidier@.discussions.microsoft.com> wrote in message
news:E0B96D78-C2B6-4A46-BE08-E7E7B7FD1893@.microsoft.com...
> I am dynamically adding an HtmlInputHidden element with different values.
> The problem is the first time I add it with a given value and submit it
then
> change the value within the Page_Load event it still has the original
value.
> I am guessing this has something to do with viewstate. I have turned off
> viewstate at the page level, but the issue still occurs. Any suggestions?
> The code is basic:
> HtmlInputHidden phihAction = new HtmlInputHidden();
> phihAction.ID = "hdnAction";
> phihAction.Value = ((short)pactAction).ToString();
> mfrmUser.Controls.Add( phihAction );
> pactAction is an enumeration that changes based on action (i.e. 1=Add,
2=Edit)
> Any help in understanding why it does what it does and how to work around
it
> would be greatly appreciated.
> --
> Robert

Saturday, March 24, 2012

PLEASE HELP = odd TextChanged behavior

I have 2 TextBox controls on a webform. Both perform a procedure when the
TextChanged event is fired. The page should reload and display a new value
in another textbox. Both are WebControls.

The first Textbox performs the appropriate action.

The SECOND does not fire TextChanged until AFTER I click the Submit button.
It does not fire when I change the text and lose the control focus. Both
code blocks for the event handlers are IDENTICAL.

Anyone know why?Just to make sure:

have you set the autopostback flag to true?

Seb.
Just to make sure:

have you set the autopostback flag to true?

Seb.
heh... *sheepish grin*

"Seb" <anonymous@.discussions.microsoft.com> wrote in message
news:073501c39869$48c82490$a501280a@.phx.gbl...
> Just to make sure:
> have you set the autopostback flag to true?
> Seb.
heh... *sheepish grin*

"Seb" <anonymous@.discussions.microsoft.com> wrote in message
news:073501c39869$48c82490$a501280a@.phx.gbl...
> Just to make sure:
> have you set the autopostback flag to true?
> Seb.

Friday, March 16, 2012

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.