Hi
I have found an issue where I cannot get ClientEvents-OnResponseEnd="onResponseEnd" ClientEvents-OnRequestStart="onResponseStart" events to fire in javascript when I do a manual postback - however the server side event code does run in ajax mode.
for instance I have an asp button in a page with a server event wrapped in an ajax panel with the 2 javascript events wired up.
If I use the mouse to click the button then it works fine - both the onResponseStart and onResponseEnd javascript functions work.
However in the folloiwng situation I want to click the button in code and not with the mouse. In this case I have wired an event for the <CR> key being clicked in a radtextbox to fire the mouse click event of the button as follows
ASCX FILE Rad Text Box that allows <CR> to be pressed and then runs the __dopostback code for a button click
<telerik:RadTextBox ID="bxPNCID" runat="server" SelectionOnFocus="SelectAll" Skin="Vista"
Width="200px" onkeydown="return OverridePostBackOnEnter(event, 'ImageButton6')">
</telerik:RadTextBox>
ASCX IMAGEBUTTON 6 - The button Click I want to emulate - I needed ClientIDMode="Static" because document.getelementbyid function needs the rendered ID rather than the aspx ID
<asp:ImageButton ID="ImageButton6" ClientIDMode="Static" runat="server" Style="float: right;
margin-top: -44px" ImageUrl="images/butt_searchcustrecoff.png" AlternateText="Search Custody Records"
ToolTip="Search Record" OnClick="SearchRecords_Click" />
JAVASCRIPT FUNCTION TO HANDLE THE KEYPRESS AND CONVERT TO MOUSE CLICK
//attach OverridePostBackOnEnter to keypress of textbox
//onkeypress="OverridePostBackOnEnter(event, 'Id of click button')" -- Firefox
//onkeydown="OverridePostBackOnEnter(event, 'Id of click button')" -- IE
//Remember set 'ClientIdMode' of controlling button to 'STATIC'
function OverridePostBackOnEnter(event, ctrl)
{
if (event.keyCode == 13)
{
if ($.browser.mozilla)
{
var overridectrl = document.getElementById(ctrl);
__doPostBack(overridectrl.name, '');
}
else
{ //for IE
//but for other browsers you should use
var overridectrl = document.getElementById(ctrl);
__doPostBack(overridectrl.name, ''); // everything I have researched says it should be uniqueID for IE but does not seem to fire the server event
}
}
};
to summarise the code above then
the radtextbox has the onkeydown event fire
the JS Routine OverridePostBackOnEnter(event, ctrl) runs and checks for the key being <CR>
The JS Routine then does the __doPostBack event.
(AjaxPanel Runs The OnResponseStart Function - DOES NOT HAPPEN)
The Server Code runs the mouse click event.
(AjaxPanel Runs The OnResponseEnd Function - DOES NOT HAPPEN)
The ajax control did not fire the onResponseStart and onResponseEnd javascript routines which do run if I click button6 using the mouse.
Any help greatly appreciated guys.
regrads Mick.
I have found an issue where I cannot get ClientEvents-OnResponseEnd="onResponseEnd" ClientEvents-OnRequestStart="onResponseStart" events to fire in javascript when I do a manual postback - however the server side event code does run in ajax mode.
for instance I have an asp button in a page with a server event wrapped in an ajax panel with the 2 javascript events wired up.
If I use the mouse to click the button then it works fine - both the onResponseStart and onResponseEnd javascript functions work.
However in the folloiwng situation I want to click the button in code and not with the mouse. In this case I have wired an event for the <CR> key being clicked in a radtextbox to fire the mouse click event of the button as follows
ASCX FILE Rad Text Box that allows <CR> to be pressed and then runs the __dopostback code for a button click
<telerik:RadTextBox ID="bxPNCID" runat="server" SelectionOnFocus="SelectAll" Skin="Vista"
Width="200px" onkeydown="return OverridePostBackOnEnter(event, 'ImageButton6')">
</telerik:RadTextBox>
ASCX IMAGEBUTTON 6 - The button Click I want to emulate - I needed ClientIDMode="Static" because document.getelementbyid function needs the rendered ID rather than the aspx ID
<asp:ImageButton ID="ImageButton6" ClientIDMode="Static" runat="server" Style="float: right;
margin-top: -44px" ImageUrl="images/butt_searchcustrecoff.png" AlternateText="Search Custody Records"
ToolTip="Search Record" OnClick="SearchRecords_Click" />
JAVASCRIPT FUNCTION TO HANDLE THE KEYPRESS AND CONVERT TO MOUSE CLICK
//attach OverridePostBackOnEnter to keypress of textbox
//onkeypress="OverridePostBackOnEnter(event, 'Id of click button')" -- Firefox
//onkeydown="OverridePostBackOnEnter(event, 'Id of click button')" -- IE
//Remember set 'ClientIdMode' of controlling button to 'STATIC'
function OverridePostBackOnEnter(event, ctrl)
{
if (event.keyCode == 13)
{
if ($.browser.mozilla)
{
var overridectrl = document.getElementById(ctrl);
__doPostBack(overridectrl.name, '');
}
else
{ //for IE
//but for other browsers you should use
var overridectrl = document.getElementById(ctrl);
__doPostBack(overridectrl.name, ''); // everything I have researched says it should be uniqueID for IE but does not seem to fire the server event
}
}
};
to summarise the code above then
the radtextbox has the onkeydown event fire
the JS Routine OverridePostBackOnEnter(event, ctrl) runs and checks for the key being <CR>
The JS Routine then does the __doPostBack event.
(AjaxPanel Runs The OnResponseStart Function - DOES NOT HAPPEN)
The Server Code runs the mouse click event.
(AjaxPanel Runs The OnResponseEnd Function - DOES NOT HAPPEN)
The ajax control did not fire the onResponseStart and onResponseEnd javascript routines which do run if I click button6 using the mouse.
Any help greatly appreciated guys.
regrads Mick.