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

controls disappear on Partial Postback

10 Answers 277 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Lee Malo
Top achievements
Rank 1
Lee Malo asked on 04 May 2010, 06:56 AM

I have a problem with 2 of my controls "disappearing" when I use the RadAjaxManager to update them when I click a button.

Here is my button:
<asp:Button runat="server" id="btnClick" OnClick="btnClick_Click" />

Here is the btnClick_Click in my C# file:

        protected void btnClick_Click(object sender, EventArgs e)
        {
            SqlConnection myConn3 = new SqlConnection("Dataconnection");
            myConn3.Open();
           
            string getCategoryQueryString;
            getCategoryQueryString = "SELECT MasterTableCategories.MasterID, MasterTableCategories.SICCode, [Sic-Codes].[SIC Name1] AS Category FROM MasterTableCategories INNER JOIN [Sic-Codes] ON MasterTableCategories.SICCode = [Sic-Codes].[SIC Code1] WHERE (MasterTableCategories.MasterID = @MasterID)";

            SqlCommand getCategoryQuery = new SqlCommand(getCategoryQueryString, myConn3);
            getCategoryQuery.Parameters.Add("@MasterID", Master_RecordID.Value);
            SqlDataReader getCategoryReader = getCategoryQuery.ExecuteReader();

            if (getCategoryReader.HasRows)
            {
                getCategoryReader.Read();
                Category.Text = getCategoryReader["Category"].ToString();
                SICCode.Value = getCategoryReader["SICCode"].ToString();
            }
            else
            {
                //For testing purposes
                Category.Text = "Cars";
                SICCode.Value = "123456789";
            }
            getCategoryReader.Dispose();
            myConn3.Close();
        }

Here is the Ajax:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel_CampaignChange">
      <AjaxSettings>
      <telerik:AjaxSetting AjaxControlID="btnClick">
          <UpdatedControls>
            <telerik:AjaxUpdatedControl ControlID="Category" />
            <telerik:AjaxUpdatedControl ControlID="SICCode" />
         </UpdatedControls>
        </telerik:AjaxSetting>
      </AjaxSettings>
    </telerik:RadAjaxManager>

Here are the controls:
<asp:TextBox ID="Category" runat="server" Width="100%" ReadOnly="true"></asp:TextBox>
<asp:HiddenField ID="SICCode" runat="server" Value="" />

The user presses the button and the btnClick_Click goes to the database and retrieves the Category and SIC Code.  It's then supposed to update the controls with string data, but makes the ENTIRE textbox and hidden field disappear from the html.  All I am left with is an empty div...sort of.  It even removes the CategoryPanel div and SICCodePanel div from the html.

If anyone has a clue why these controls vanish, I would appreciate it immensely!

10 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 07 May 2010, 11:24 AM
Hello Lee Malo,

Please check the following:

1. Do you get a valid server response during the AJAX request?

2. Are there any Javascript errors on the page?

3. Is the page HTML markup valid?

If all the points above seem OK, please send a simple runnable sample and we will inspect it locally. Thanks,

Regards,
Dimo
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
John
Top achievements
Rank 1
answered on 21 Feb 2011, 11:49 AM
Hi,
Was there ever any outcome to this problem?  I'm having exactly the same issue.  The server side is assigning the correct value to the text box but when the page redisplays the text box has vanished.

Thanks

John
0
Maria Ilieva
Telerik team
answered on 24 Feb 2011, 01:13 PM
Hello John,

Could you please elaborate a bit more on the scenario you have and provide answers of the previously posted support questions?



Kind regards,
Maria Ilieva
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
John
Top achievements
Rank 1
answered on 24 Feb 2011, 04:24 PM
Certainly,

I have an aspx page that contains a number of required text boxes.  One of the boxes can be optionally filled with a default value by pressing a button on the form.  Ajax is required to circumvent the posting of the whole form as most of the other required boxes will not be filled when the button is pressed.  So I set it up as follows...

In the radajax manager settings I have

<telerik:AjaxSetting AjaxControlID="btnCompName">

<UpdatedControls>

<telerik:AjaxUpdatedControl ControlID="txtComponentId"

LoadingPanelID="loading" />

</UpdatedControls>

</telerik:AjaxSetting>


Following the loading pannel set up is

<telerik:RadCodeBlock ID="cb1" runat="server">

<script type="text/javascript">

function AjaxRequestButton(arguments)

{

var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");

ajaxManager.ajaxRequestWithTarget('<%= btnCompName.UniqueID%>', '');

}

</script>

</telerik:RadCodeBlock>

Then in a form table I have.

<

 

 

td class="style6">

 

 

 

<asp:TextBox ID="txtComponentId" runat="server" MaxLength="50" Width="200px"></asp:TextBox>

 

 

 

&nbsp;

 

 

 

&nbsp;

 

 

 

<input type="button" onclick="AjaxRequestButton(); return false;" style="visibility:hidden" />

 

 

 

<asp:Button ID='btnCompName' runat='server' CssClass='library_button' Height='23' Width='55'

 

 

 

 

OnClick='btnCompName_Click' Text='Name it' />

 

 

 

</td>

In the code behind the page I have

 

 

 

 

protected void btnCompName_Click(object sender, System.EventArgs e)

 

 

{

 

 

 

componentBLL objcomponentBLL = new componentBLL();

 

 

 

 

string NextCID = objcomponentBLL.GiveCompName().ToString();

 

 

txtComponentId.Text = NextCID;

 

 

 

//btnCompName.Enabled = false;

 

 

}

When I press the button, the text box vanishes.  Tracing through the code shows that the text box is being set to the correct value.
 To answer the support questions, The server is sending the correct value, there's no java errors or html markup errors.  Apart from this issue, the rest of the page works perfectly.

Any suggestions?

Thanks in advance.

John.


0
Maria Ilieva
Telerik team
answered on 25 Feb 2011, 02:18 PM
Hi Lee Malo,

Could you please try adding setting into your RadAjaxManager settings in which the AjaxManager itself updates the mentioned textbox?
Give this suggestion a try and let me know how it goes.

Greetings,
Maria Ilieva
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
John
Top achievements
Rank 1
answered on 01 Mar 2011, 10:08 AM
Hi,
Thanks for your reply.  I tried your suggestion but sadly it didn't make a difference.  The text box still dissappeared.  DO you have any other suggestions please?

Kind Regards

JOhn.
0
Maria Ilieva
Telerik team
answered on 07 Mar 2011, 10:34 AM
Hi Lee,


 It will be very helpful if you could open a regular support ticket and send us sample runnable application which demonstrates the issue you are facing. Thus we will be able to debug it locally and isolate the root cause of the presented problem.


All the best,
Maria Ilieva
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Calvin
Top achievements
Rank 1
answered on 02 Jun 2011, 11:06 PM
I'm having the exact same problem, did we ever find out why this happens?
0
Mahdi
Top achievements
Rank 1
answered on 16 Sep 2014, 04:10 AM
I know it's an old thread but exact same problem with 2014.1.403 trial!
I am trying to replace AjaxControlToolkit with telerik. I have webusercontrol loaded and added dynamically at pageinit. This user control has a RadWindow. In the RadWindow when I do a partial postback using AjaxManagerProxy the affected controls dissapear from the RadWindow contents. Although I found them on the main page! 
No js errors and postback does it job well on server side. The values are also correctly set.
Any solution?!
0
Maria Ilieva
Telerik team
answered on 18 Sep 2014, 02:37 PM
Hello,

In most cases the described issue appear when the UserControls are not properly loaded on the page. Please make sure that the controls are added on each postback.
I would suggest you to open separate threads for the specific cases you have and post your page markup and related code behind. Thus we will be bale to further investigate your scenarios and advise you for possible solutions.

Regards,
Maria Ilieva
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Ajax
Asked by
Lee Malo
Top achievements
Rank 1
Answers by
Dimo
Telerik team
John
Top achievements
Rank 1
Maria Ilieva
Telerik team
Calvin
Top achievements
Rank 1
Mahdi
Top achievements
Rank 1
Share this question
or