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

how fire my javascript on backcode?

2 Answers 62 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Y
Top achievements
Rank 1
Y asked on 09 Nov 2011, 08:54 AM

Dear Telerik,

    I use a grid,when I add new record,I want fire a function of my js script.but I use the radajax so I use  ClientScript.RegisterStartupScript  function is unuseful...
    my code:
    

function showEdit(customer, contact) {
    window.radopen("ContactEdit.aspx?cus=" + customer + "&contact=" + contact, "EditContact");
    return false;
}

protected void RadGridList_InsertCommand(object sender, GridCommandEventArgs e)
{
    Parents parents = new Parents();
    parents.Customer_No = ((TextBox)e.Item.FindControl("txtParentsCode")).Text.Trim();
    parents.English_Name = ((TextBox)e.Item.FindControl("txtEnName")).Text.Trim();
    parents.Join_Date = DateTime.Parse(((RadDatePicker)e.Item.FindControl("rdpJoinDate")).SelectedDate.ToString());
    parents.Salesman_Code = ((RadComboBox)e.Item.FindControl("rcbSalesman")).SelectedValue.Trim();
    parents.BR_No = ((TextBox)e.Item.FindControl("txtBRNo")).Text.Trim();
    parents.CR_No = ((TextBox)e.Item.FindControl("txtCRNo")).Text.Trim();
    parents.Remarks = ((TextBox)e.Item.FindControl("txtRemarks")).Text.Trim();
    parents.Parent_Customer_No = ((RadComboBox)e.Item.FindControl("rcbParent")).SelectedValue.Trim();
    parents.Alternative_Name = ((TextBox)e.Item.FindControl("txtAlternative")).Text.Trim();
    parents.Music_Service_Type = ((TextBox)e.Item.FindControl("txtMusSerType")).Text.Trim();
    parents.Next_Contact_Datetime = DateTime.Parse(((RadDatePicker)e.Item.FindControl("rdpNextConDate")).SelectedDate.ToString());
    try
    {
        new BLL.ParentsBLL().Add(parents);
        BindData();
        ClientScript.RegisterStartupScript(GetType(), "message", "<script language='javascript'>showEdit('0004', '')</script>");
    }
    catch (Exception)
    {
        throw;
    }
}

2 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 09 Nov 2011, 10:38 AM
Hello Y,

To achieve your goal, you can use either the ResponseScripts collection of the ajax manager/panel or the ScriptManager.RegisterStartupScript static method. See this topic for more info.

Best regards,
Sebastian
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Y
Top achievements
Rank 1
answered on 10 Nov 2011, 08:26 AM
 ok,thanks!
Tags
General Discussions
Asked by
Y
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Y
Top achievements
Rank 1
Share this question
or