Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

Update Panel - I know why not sure how to fix

I know why this is happening but not sure how to fix it.

I have a panel like this in an UpdatePanel:
<div id="pnlOrderItems" runat="server">
     <updatepanel>
           <asp:Button runat="server" ...>

I click on that button and I want to update a text on a linkbutton THAT IS OUTSIDE that updatepanel. Code is correct but i think because that textbox is outside the panel, that's why it doesnt get updated.

Anyway to do this? This is the linkbutton i want to update. The text remains as "No Data". If I come back to the page, it shows the correct text.

***If I make the linkbutton part of the updatepanel, then it works. I cant do this tho because of the position of the link button. It has to be on top.
<asp:Content ID="Content2" ContentPlaceHolderID="PageMenu" Runat="Server">
 
 
 <asp:Button ID="hlViewTranHistory"     Visible="false"   runat="server"/>
 <asp:Label ID="lblNoTransactions" runat="server"  Visible="false" Text="No Data."></asp:Label>
 
</asp:Content>

Open in new window

Avatar of GiftsonDJohn
GiftsonDJohn
Flag of India image

On the button_click event on the server side, invoke a javascript function

ScriptManager.RegisterClientScriptBlock(Button1, Button1.GetType(), "changevalue", "document.getElementById('" + LinkButton1.ClientID + "').value='" + "value to be set" + "';", true);
you can put the link button in its own update panel.  what does the linkbutton update?
have the other button be the trigger for that update panel...
Avatar of Camillia

ASKER

>> you can put the link button in its own update panel.  what does the linkbutton update?
I did that but the button wont display at all

>> have the other button be the trigger for that update panel...
How?

>> GiftsonDJohn:
I havent tried your method. I will
I tried the Javascript method. I put it in the grid's itemdatabound. Didnt work.

wrapped the button in another update panel. It just wont display.

I dont know what the 3rd method mean:  have the other button be the trigger for that update panel...
like
<asp:Updatepanel....>
contentTemplate

<asp:linkbutton...>
</contentTemplate>
<triggers>
<asyncy...controlID = "OtherButton">


or you could set the updatePanel which holds the link button to: UpdateMode="Always"> since its only the button
let me try it. Thanks for responding again. thought u guys forgot.
didnt work. That "otherbutton" is inside a Grid. So, it cant be seen. I did below and got an error that btnProcess cannot be found
<asp:UpdatePanel runat="server">
  <ContentTemplate>
     <asp:Button ID="hlViewTranHistory"   Visible="false"   runat="server"/>
     <asp:Label ID="lblNoTransactions" runat="server"  Visible="false" Text="No View." ></asp:Label>
</ContentTemplate>
<Triggers><asp:AsyncPostBackTrigger ControlID="btnProcess" /></Triggers>
</asp:UpdatePanel>

Open in new window

Here you go.

Add Grid as control and RowCommand event for the trigger
>>Add Grid as control and RowCommand event for the trigger
not sure what u mean.
i guess maybe you should give some background on what you're trying to do and why you implemented code this way if possible...
I didn't realize the button was in a grid until just now...
ASKER CERTIFIED SOLUTION
Avatar of silemone
silemone
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
giftson, that is another way that I agree should work...
only thing if you can get it to work with javascript, it may be quicker...
>>  declare the event to be executed as asynchronous is RowCommand

so create a RowCommand for the Grid and in that RowCommand, update the control outside the updatepanel??
If you want an asynchronous update, both of them should be inside update panel.

<asp:UpdatePanel ID=UpdatePanel1>
<ContentTemplate
   <asp:Grid ID=Grid1> </Grid>
</ContentTemplate>
</asp:UpdatePanel

<UpdatePanel ID=UpdatePanel2>
<ContentTemplate>
<asp:Button ID="hlViewTranHistory"   Visible="false"   runat="server"/>
</ContentTemplate>
<Triggers>
   <asp:AsyncPostBackTrigger ControlID="Grid1" EventName="RowCommand" />
  </Triggers>
</UpdatePanel>
when I put Button ID="hlViewTranHistory"  inside an updatepanel, it disappears. Not sure why. So, I want it outside the updatepanel. What is that "RowCommand" method you mentioned?
wroks now. Thanks you both.