Showing posts with label onload. Show all posts
Showing posts with label onload. Show all posts

Saturday, March 24, 2012

set focus after postback

How can I set the focus to a control after postback?I have some javascript function to set the focus in onload event,but it looks like the onload event is not trigger after postback.ThanksThis will do what you want:
-- focus and select in a textbox
Dim sb As New System.Text.StringBuilder

sb.Append("<script language=javascript>")
sb.Append("document.forms.myForm.txtMyBox.focus();")
sb.Append("document.forms.myForm.txtMyBox.select();")
sb.Append("</script>")

If Not IsStartupScriptRegistered("MyBoxSelect") Then
RegisterStartupScript("MyBoxSelect", sb.ToString())
End If


Also, you might have a look @.view post 821121

regards

Thursday, March 22, 2012

Set hidden values and then submit automatically

>From my page shopping cart page I want to send the amount value to the
following payment page:

<script type="text/javascript">
window.onload = function (evt) { document.forms[0].submit(); }
</script>

</head>

<body>
<form name="payform" method="post"
action="https://mmm.com/payment/start.pml">
<input type="hidden" id="amount" name="amount" value=""
runat="server" />
<input type="hidden" name="merchant" value="752" />
</form>

The amount value should be set in the hidden input and then the form
should be submitted autmatically to the payment company. I have
problems capturing and setting the amount value.

I've tried with:

Sub Page_load()
amount.Value = 1212
End Sub

But I receive an error message from the payment company telling me that
amount is missing.

Can someone help me think clear?

Regards,

SDid you check if the value is getting set in the hidden variable before
calling forms[0].submit function?

Regards,
Augustin
http://augustinprasanna.blogspot.com
"staeri@.gmail.com" wrote:

Quote:

Originally Posted by

Quote:

Originally Posted by

From my page shopping cart page I want to send the amount value to the


following payment page:
>
<script type="text/javascript">
window.onload = function (evt) { document.forms[0].submit(); }
</script>
>
</head>
>
<body>
<form name="payform" method="post"
action="https://mmm.com/payment/start.pml">
<input type="hidden" id="amount" name="amount" value=""
runat="server" />
<input type="hidden" name="merchant" value="752" />
</form>
>
The amount value should be set in the hidden input and then the form
should be submitted autmatically to the payment company. I have
problems capturing and setting the amount value.
>
I've tried with:
>
Sub Page_load()
amount.Value = 1212
End Sub
>
But I receive an error message from the payment company telling me that
amount is missing.
>
Can someone help me think clear?
>
Regards,
>
S
>
>



"staeri@.gmail.com" wrote:

Quote:

Originally Posted by

Quote:

Originally Posted by

From my page shopping cart page I want to send the amount value to the


following payment page:
>
<script type="text/javascript">
window.onload = function (evt) { document.forms[0].submit(); }
</script>
>
</head>
>
<body>
<form name="payform" method="post"
action="https://mmm.com/payment/start.pml">
<input type="hidden" id="amount" name="amount" value=""
runat="server" />
<input type="hidden" name="merchant" value="752" />
</form>
>
The amount value should be set in the hidden input and then the form
should be submitted autmatically to the payment company. I have
problems capturing and setting the amount value.
>
I've tried with:
>
Sub Page_load()
amount.Value = 1212
End Sub
>
But I receive an error message from the payment company telling me that
amount is missing.
>
Can someone help me think clear?


If you want to set it using page_load, could you not edit your HTML source
and use:

<input type="hidden" id="amount" name="amount" value="<%=intAmount%>"
runat="server" />

and declare and set intAmount somewhere else?