registerhiddenfield question

A

Ashish

hi All,

Iam registering a hidden field on certain logic, and some java script
sets the value
while the page postback i wanna check if the field is present on the form

what iam trying to do is :

RegisterHiddenField("fldPopupSubmit","1")

and on the page load

Dim l As Object = CType(Me.FindControl("fldPopupSubmit"), Object)
If Not l Is Nothing Then
' process certain logic
End If


is this possible at all ?

if not what can be another way to do this ?

TIA
-ashish
 
S

Steve C. Orr [MVP, MCSD]

Yes, this should be possible.
Have you tried it?
If it doesn't work tell us the error.
 
A

Ashish

Steve said:
Yes, this should be possible.
Have you tried it?
If it doesn't work tell us the error.

what iam trying to do is to get an acknowledgement from a user depending
on some server side logic,
so i use RegisterStartupScript() to populate java script with a confirm
function, if the user clicks OK then the javasctipt itself submits the
form..

to indicate that it is submitted by the javascript i dynamically insert
a hidden field so that on submission i know that it is submitted by the
javascript ....

when i do findcontrol("myhiddenfield") after the submission by
javascript, it does not finds the field

the javascript is :

agree = confirm('do you wanna do this ?');
if (agree) {
document.forms[0].submit;
}


all this is done to beat the popup blockers ...


any help would be appreciated

-ashish
 
S

Steve C. Orr [MVP, MCSD]

Yes, I've done this kind of thing before.
I put the hidden field in there permanently, then I would fill it in with a
specific value (using javascript) when the user responded to my message box.
That way you don't have to work about finding the control because it's
always there. It's just the value in it that may change.
If you have any specific questions, fire away.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


Ashish said:
Steve said:
Yes, this should be possible.
Have you tried it?
If it doesn't work tell us the error.

what iam trying to do is to get an acknowledgement from a user depending
on some server side logic,
so i use RegisterStartupScript() to populate java script with a confirm
function, if the user clicks OK then the javasctipt itself submits the
form..

to indicate that it is submitted by the javascript i dynamically insert
a hidden field so that on submission i know that it is submitted by the
javascript ....

when i do findcontrol("myhiddenfield") after the submission by
javascript, it does not finds the field

the javascript is :

agree = confirm('do you wanna do this ?');
if (agree) {
document.forms[0].submit;
}


all this is done to beat the popup blockers ...


any help would be appreciated

-ashish
 
A

Ashish

Steve said:
Yes, this should be possible.
Have you tried it?
If it doesn't work tell us the error.
what iam trying to do is to get an acknowledgement from a user depending
on some server side logic,
so i use RegisterStartupScript() to populate java script with a confirm
function, if the user clicks OK then the javasctipt itself submits the
form..

to indicate that it is submitted by the javascript i dynamically insert
a hidden field so that on submission i know that it is submitted by the
javascript ....

when i do findcontrol("myhiddenfield") after the submission by
javascript, it does not finds the field

the javascript is :

agree = confirm('do you wanna do this ?');
if (agree) {
document.forms[0].submit;
}


all this is done to beat the popup blockers ...


any help would be appreciated

-ashish
 
A

Ashish

Steve said:
Yes, I've done this kind of thing before.
I put the hidden field in there permanently, then I would fill it in with a
specific value (using javascript) when the user responded to my message box.
That way you don't have to work about finding the control because it's
always there. It's just the value in it that may change.
If you have any specific questions, fire away.

hi Steve,

Can i get away with putting the field dynamically ?, the issue is that
in my project page classes are having hierarchy, and pages can use a
number of controls, configurable by user ...

so if i use RegisterHiddenField, will i be able to do findcontrol on it ..


right now, i dont see the field i register ....

thanks again
-ashish
 
S

Steve C. Orr [MVP, MCSD]

You might want to visually scan the HTML source that is output to the
browser and see if the field is there and verify ASP.NET hasn't renamed it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top