vs_mkazanova
asked on
Partial Postback via HTML Radio Button in Gridview
I'm creating HTML radiobuttons in GridView dynamically on GridView's RowCreated events as below:
if (e.Row.RowType == DataControlRowType.DataRow )
{
Literal output = (Literal)e.Row.FindControl ("plcholdR adioButton ");
output.Text = string.Format(
@"<input type=""radio"" name=""ContactGroup"" " +
@"id=""RowSelector{0} "" onClick=""AJAXPostback('Ro wSelector{ 0}');"" value=""{0}""", e.Row.RowIndex);
if (MainContactSelectedIndex == e.Row.RowIndex)
{
output.Text += @" checked=""checked""";
ViewState["MainClientId"] = DataBinder.Eval(e.Row.Data Item, "clid");
}
output.Text += " />";
}
GridView is in UpdatePanel which is hosted in Master Page, when click one of this radio buttons in gridview it fires up the following javascript:
function AJAXPostback(element)
{
var grgDynControl = document.getElementById('e lement');
var prm = Sys.WebForms.PageRequestMa nager.getI nstance();
prm._doPostBack('grgDynCon trol','');
}
These all works fine but it does full page postback instead of partial postback. How can i achieve the partial postback with this system?
if (e.Row.RowType == DataControlRowType.DataRow
{
Literal output = (Literal)e.Row.FindControl
output.Text = string.Format(
@"<input type=""radio"" name=""ContactGroup"" " +
@"id=""RowSelector{0} "" onClick=""AJAXPostback('Ro
if (MainContactSelectedIndex == e.Row.RowIndex)
{
output.Text += @" checked=""checked""";
ViewState["MainClientId"] = DataBinder.Eval(e.Row.Data
}
output.Text += " />";
}
GridView is in UpdatePanel which is hosted in Master Page, when click one of this radio buttons in gridview it fires up the following javascript:
function AJAXPostback(element)
{
var grgDynControl = document.getElementById('e
var prm = Sys.WebForms.PageRequestMa
prm._doPostBack('grgDynCon
}
These all works fine but it does full page postback instead of partial postback. How can i achieve the partial postback with this system?
ASKER
Can you post code for this?
if (e.Row.RowType == DataControlRowType.DataRow )
{
Literal output = (Literal)e.Row.FindControl ("plcholdR adioButton ");
output.Text = string.Format(
@"<input type=""radio"" name=""ContactGroup"" " +
@"id=""RowSelector{0} "" onClick=""__doPostBack('ln kButton',' ');"" value=""{0}""", e.Row.RowIndex);
if (MainContactSelectedIndex == e.Row.RowIndex)
{
output.Text += @" checked=""checked""";
ViewState["MainClientId"] = DataBinder.Eval(e.Row.Data Item, "clid");
}
output.Text += " />";
}
Then in your UpdatePanel, add a LinkButton
<asp:LinkButton ID="btnFinished" runat="server" Text="Finished" style="display:none" />
And if you need a trigger:
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnFinished" EventName="Click" />
</Triggers>
{
Literal output = (Literal)e.Row.FindControl
output.Text = string.Format(
@"<input type=""radio"" name=""ContactGroup"" " +
@"id=""RowSelector{0} "" onClick=""__doPostBack('ln
if (MainContactSelectedIndex == e.Row.RowIndex)
{
output.Text += @" checked=""checked""";
ViewState["MainClientId"] = DataBinder.Eval(e.Row.Data
}
output.Text += " />";
}
Then in your UpdatePanel, add a LinkButton
<asp:LinkButton ID="btnFinished" runat="server" Text="Finished" style="display:none" />
And if you need a trigger:
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnFinished" EventName="Click" />
</Triggers>
Sorry, that should be lnkButton, not btnFinished.
Then in your UpdatePanel, add a LinkButton
<asp:LinkButton ID="lnkButton" runat="server" Text="Update" style="display:none" />
And if you need a trigger:
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnkButton" EventName="Click" />
</Triggers>
Then in your UpdatePanel, add a LinkButton
<asp:LinkButton ID="lnkButton" runat="server" Text="Update" style="display:none" />
And if you need a trigger:
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnkButton" EventName="Click" />
</Triggers>
ASKER
I've tested but page still flickers, and progress bar on the browser shows up on the bottom.
Is the page live so I can see it? Or can you post some code?
I just tested this and it is working fine. The button does an async postback whether it's inside the updatepanel or outside, since the trigger is defined.
I just tested this and it is working fine. The button does an async postback whether it's inside the updatepanel or outside, since the trigger is defined.
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:LinkButton ID="btnFinished" runat="server" Text="Finished" Style="display: none;" />
<input type="button" value="button" onclick="__doPostBack('btnFinished','')" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnFinished" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFinished.Click
Label1.Text = Now.ToLongTimeString
End Sub
ASKER
no it's on intranet,
master page holds the update panel which i have contentplaceholder inside
and content page has the gridview that hosts the gridview with radiobuttons.
master page holds the update panel which i have contentplaceholder inside
and content page has the gridview that hosts the gridview with radiobuttons.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That was it, as soon as i placed ctl00$lnkButton in doPostBack, it put me back into business.
Thank you for yor help!
Thank you for yor help!
If you have childrenastriggers set to true, it will do a partial postback, if not just add a trigger for lnkUpdate