Showing posts with label rows. Show all posts
Showing posts with label rows. Show all posts

Wednesday, March 28, 2012

Programmatically created Submit button on UpdatePanel want fire without The UpdatePanel be

I have programmatically created some controls(labels, buttons) that make up and object in several rows of a table on an UpdatePanel. On the initial load of the page, I create all the objects(controls). Then I click one of the buttons to do a partialrendering update of some the controls in the UpdatePanel. The button click causes a post back which I throught was good. The problem is that if i do not refesh the entire set of controls on the UpdatePanel first, the button click want fire and I can't firgure out why.

Here is some of the code:

<asp:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"AsyncPostBackTimeout="36000"/><asp:UpdatePanelID="UpdatePanel2"runat="server"ChildrenAsTriggers="false"UpdateMode="Conditional"><ContentTemplate><asp:TableID="Table1"runat="server"></asp:Table><asp:UpdateProgressID="UpdateProgress"runat="server"AssociatedUpdatePanelID="UpdatePanel2"><ProgressTemplate>

Processing Service Request .........

</ProgressTemplate></asp:UpdateProgress></ContentTemplate></asp:UpdatePanel>

protectedvoid btnSubmit_Click(object sender,EventArgs e)

{

RefreshStatus(); --> Causes controls to be built on UpdatePanel.

}

protectedvoid Page_Load(object sender,EventArgs e)

}

if (!IsPostBack)

{

}

else

{

<-- If I do a"RefreshStatus();"here, all works fine but the entire set of controls on the UpdatePane is re-Built. Not what I want.

}

Button Click:

void ChangeStatus_Click(object sender,EventArgs e)

{

Button ChangeStatus = (Button)sender;

----- Update subset of controls on UpdatePanel here -------

}

Since there is no ReFreshStatus() during the postback the button wantfire and nothing happens. I am puzzel by this.

Any Ideas?

Thanks

I forgot mention the each button is built with a AsyncPostBack trigger, ie:

// Add Updatepanel Triggers for the buttonAsyncPostBackTrigger trigForBtns;

trigForBtns =

newAsyncPostBackTrigger();

trigForBtns.ControlID = ChangeStatus.ID;

trigForBtns.EventName =

"Click";

Thanks again, I really need some help with this.


I just wanted to mention that I solved this problem byImplementing Ajax incremental asynochronous updating of controls on the web page.


Thats niceSmile

Can you post some code details here ?

Saturday, March 24, 2012

Question about OnClientClick for asp:LinkButton...

I have the code:

Code Behind .vb file:

Dim lbAsNew LinkButton

lb.Text = dt.Rows(j).Item(

0)

lb.ID =

"cat" +CType(dt.Rows(j).Item(1),String)

lb.CssClass =

"lbH1"

lb.OnClientClick =

"lb_Click('" +CType(dt.Rows(j).Item(1),String) +"')"

tc.Controls.Add(lb)

Client Side .aspx file:

<scriptlanguage="javascript"type="text/javascript">function lb_Click(e){

alert(e);

}

</script>

How can I tie this code in to talk to a Page Method or WebService? Any good simple links/tutorials? I tried the Ajax video page but apparently the sound drops out half way through the video? And my books refer to 'Atlas' instead of 'Ajax 1 or 2'.

You can add a onclick event handler like this:

AddHandler lb.OnClick, AddressOf lb_Click

And define a event handler method as below:

Protected Sub lb_Click(sender as object, E as EventArgs)

End Sub

If want to execute it asynchronously, you can decorate the above method with WebMethod attribute. Like this:

<WebMethod()> Protected Sub lb_Click(sender as object, E as EventArgs)

End Sub