This is a migrated thread and some comments may be shown as answers.

[Solved] Postback on Onblur event

2 Answers 325 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vanika
Top achievements
Rank 1
Vanika asked on 25 Jun 2009, 05:22 AM
Hi,

I have a asp.net gridview in a radpagepiew. The gridview has 3 editable textboxes. On the "onblur" event of the third textbox, I want to first execute a javascript code, and then a server side code. I need the postback to be ajaxified.
I have used the following code

<

 

asp:Button runat = "server" ID = "btnPsuedoButton" Visible="true" OnClick="btnPsuedoButton_Click" />

In the RowDatabound event of the gridview, I do

 

string

 

eventHandler = this.GetPostBackEventReference(this.btnPsuedoButton, "");

 

txtDescription.Attributes.Add(

"OnBlur", eventHandler);

My problems are
1. If I make the button btnPsuedoButton invisible, I get error on page
2. How do I make the postback ajaxified.
3. How to call a javascript before the btnPsuedoButton_Click event

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 Jun 2009, 09:09 AM
Hi Vanika,

One sugestion is by using ajaxRequest() method of RadAjaxManager (or RadAjaxPanel) to initiate a generic AJAX request instead of using Button for postback.

Have a look at the example that I tried.
ASPX:
 
<telerik:radajaxmanager id="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">  
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">  
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="TextBox1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:radajaxmanager> 
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
Note: Set the AjaxUpdatedControl-ControlID to the controlId that you want to update.

JavaScript:
 
<script type="text/javascript">  
function eventHandler()  
{  
    // Your client side code  
    $find("<%=RadAjaxManager1.ClientID%>").ajaxRequest(''); // Ajax Request  
}  
</script> 

C#:
 
protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)  
{  
    // Your server side code  

Note: Add the OnBlur attribute for TextBox in the RowDataBound event as shown below.
 
txtDescription.Attributes.Add("OnBlur""eventHandler();"); 

Thanks,
Princy.
0
Vanika
Top achievements
Rank 1
answered on 25 Jun 2009, 02:25 PM
The textbox whose onblur event is to be called is a templatefield in a grid.
So I tried

<

 

telerik:radajaxmanager id="RadAjaxManager2" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">

 

 

<AjaxSettings>

 

 

<telerik:AjaxSetting AjaxControlID="SalaryBandGrid">

 

 

<UpdatedControls>

 

 

<telerik:AjaxUpdatedControl ControlID="SalaryBandGrid" />

 

 

</UpdatedControls>

 

 

</telerik:AjaxSetting>

 

 

</AjaxSettings>

 

</

 

telerik:radajaxmanager>

 


But this does not updatethe grid, though the datasource of the grid gets updated in the codebehind.
Also, how do I attach thw ajax call with the ajax loading image ?
Tags
General Discussions
Asked by
Vanika
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Vanika
Top achievements
Rank 1
Share this question
or