473,503 Members | 3,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

call __doPostBack from javascript method not working as expected

Hi!
I want to make a postback when the user hits the escape-button on the
keyboard and redirect the user to another page. But the
response.redirect does not work for me in this "context".
I´m trying to do like this:
<body onkeydown="MyRedirect()">
function MyRedirect()
{
if(event.keyCode == 27)
{
__doPostBack('', 'myRedirect');
}
}
--
The doPostBack method is autogenerated by .net and look like this in
..net 2.0.
--

function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
--

This will trigger a postback.
In page_load I´m doing like this:
Private Sub Page_Load(...) Handles Me.Load
If Page.IsPostBack Then
If Request.Form("__EVENTARGUMENT") = "myRedirect" Then
response.redirect("anotherPage.aspx")
End If
End If
End Sub
Nothing happens when executing response.redirect. Why is that?
Thanks in advance
/ Steve

Nov 19 '05 #1
2 3902
Response.Reddirect is simply not executed.
Most likely IsPostBack return false.
Leve the code like that
If Request.Form("__EVENTARGUMENT") = "myRedirect" Then
response.redirect("anotherPage.aspx")
End If
you do not need to check on PostBack

George.
"SteveSu" <ss*********@hotmail.com> wrote in message news:11**********************@g44g2000cwa.googlegr oups.com...
Hi!
I want to make a postback when the user hits the escape-button on the
keyboard and redirect the user to another page. But the
response.redirect does not work for me in this "context".
I´m trying to do like this:
<body onkeydown="MyRedirect()">
function MyRedirect()
{
if(event.keyCode == 27)
{
__doPostBack('', 'myRedirect');
}
}
--
The doPostBack method is autogenerated by .net and look like this in
.net 2.0.
--

function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
--

This will trigger a postback.
In page_load I´m doing like this:
Private Sub Page_Load(...) Handles Me.Load
If Page.IsPostBack Then
If Request.Form("__EVENTARGUMENT") = "myRedirect" Then
response.redirect("anotherPage.aspx")
End If
End If
End Sub
Nothing happens when executing response.redirect. Why is that?
Thanks in advance
/ Steve

Nov 19 '05 #2
Thanks for the reply.
This is not the case. I have steped through the code in the debugger
som I know that the response.redirect line is executed.
The strange thing is that it does not seems to be an ordinary postback,
cause if I for example change the text-value for a label, the value is
not changed when the page is shown again.
I have tested the same thing for a LinkLabel. First I add a linklabel
to the page. In the event for the linklabel I have added a
response.redirect. This works fine if I click on the link, but if I
call it from a javascript method like __doPostBack('LinkButton1', '')
the event is called but no response.redirect is done. What is the
difference between this scenarios?
George wrote:
Response.Reddirect is simply not executed.
Most likely IsPostBack return false.
Leve the code like that
If Request.Form("__EVENTARGUMENT") = "myRedirect" Then
response.redirect("anotherPage.aspx")
End If
you do not need to check on PostBack

George.
"SteveSu" <ss*********@hotmail.com> wrote in message news:11**********************@g44g2000cwa.googlegr oups.com...
Hi!
I want to make a postback when the user hits the escape-button on the
keyboard and redirect the user to another page. But the
response.redirect does not work for me in this "context".
I´m trying to do like this:
<body onkeydown="MyRedirect()">
function MyRedirect()
{
if(event.keyCode == 27)
{
__doPostBack('', 'myRedirect');
}
}
--
The doPostBack method is autogenerated by .net and look like this in
.net 2.0.
--

function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
--

This will trigger a postback.
In page_load I´m doing like this:
Private Sub Page_Load(...) Handles Me.Load
If Page.IsPostBack Then
If Request.Form("__EVENTARGUMENT") = "myRedirect" Then
response.redirect("anotherPage.aspx")
End If
End If
End Sub
Nothing happens when executing response.redirect. Why is that?


Thanks in advance
/ Steve


Nov 19 '05 #3

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

Similar topics

2
2373
by: sathya | last post by:
hi, i am using regexp.index in my javascript, IE supports this value but mozilla gives undefined value for regexp.index. Is there any equivalent method we can use for mozilla browsers. ...
1
2097
by: Jack Black | last post by:
OK, I've got a basic webform set up, with several buttons that I want to trigger different things on when they're clicked. For example, when the onClick event is triggered on one, I want a...
3
2109
by: Fredrik Elestedt | last post by:
Hi, I have a problem with the __dopostback script when I run my webbapplication on certain servers. The code is not recompiled and the aspx filer are untouched... This is what happens, on a...
9
4887
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
0
881
by: Filippo Bettinaglio | last post by:
Hi, VS2005, C# I have developed a UserControl embedded in a HTML web page. How can I call a JavaScript Method (in my HTML) from the UserControl? Many Thanks,
0
956
by: Vincent Courcelle | last post by:
Hello, I'm using the Atlas framework to build some dynamic applications. I need to call a javascript method when datas arrives (but after Atlas renders the result). It is possible to do so ? ...
2
4674
by: tarinip | last post by:
Hi, How to call a javascript method from XAML. I am using C# . In the following example, When I click button1, I wish to call a method by name "SetValue(somevalue)" of TestIndex.html file....
7
6902
by: PhilTheGap | last post by:
Hi, I've tried this: <asp:Button ID="Save" runat="server" Text="OK" OnClick="ServerSave" OnClientClick="SaveParam (<% Util.MaxTags %>)" /> but if fails... Util is a C# class, MaxTags a...
2
6923
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html ...
0
7188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7063
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7258
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5558
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
366
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.