I have a grid where you can select items, a drop down and a button. You can select an action from the dropdown and the click the button to open the modal dialog. I need to put the id of the selected items in the Session first (IMPORTANT!), and then I need to open a Modal Dialog from code behind. I have tried a few solutions but the client code always get executed before the server code.
Thanks in advance,
UPDATE
This is the code in the aspx page
function ShowLightBox(pageUrl, lightBoxTitle, moreOptions) { options = { url: pageUrl, autoSize: true, title: lightBoxTitle } SP.UI.ModalDialog.showModalDialog(options); yPos = $(window.parent.document).scrollTop() + 20; $(".ms-dlgContent", window.parent.document).css({ position: 'fixed', top: yPos }); }<telerik:RadComboBox ID="rcActions" runat="server" DataTextField="Key" DataValueField="Value"> </telerik:RadComboBox> <asp:Button ID="btnGo" runat="server" Text="GO" OnClick="btnGo_OnClick" />
<telerik:RadGrid ID="radGrid1" runat="server" AutoGenerateColumns="false" AllowPaging="true" OnNeedDataSource="radGrid1_OnNeedDataSource" OnItemCommand="radGrid1_ItemCommand" OnColumnCreated="radGrid1_OnColumnCreated"
OnItemDataBound="radGrid1_OnItemDataBound">
<MasterTableView AutoGenerateColumns="false" NoMasterRecordsText="<%$Resources:GlobalResource, noRecords%>">
<Columns>
<telerik:GridBoundColumn DataField="Id" UniqueName="Id" Visible="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="UnitNumber" UniqueName="UnitNumber" Visible="false">
</telerik:GridBoundColumn>
<telerik:GridClientSelectColumn UniqueName="Selected">
</telerik:GridClientSelectColumn>
</Columns>
<NestedViewSettings>
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="Id" MasterKeyField="Id" />
</ParentTableRelation>
</NestedViewSettings>
<NestedViewTemplate>
<asp:Panel runat="server" Visible="false" ID="InnerContainer">
<!-- Some code -->
</asp:Panel>
</NestedViewTemplate>
</MasterTableView>
</telerik:RadGrid>
This is the code behind
protected void btnGo_OnClick(object sender, EventArgs e)
{
try
{
var unitNumbers = new List<string>();
foreach (GridItem unit in radGrid1.SelectedItems)
{
var gridInfo = new GridInfo(unit);
unitNumbers.Add(gridInfo.UnitNumberCell.Text);
}
if (Session["UnitNumbers"] != null)
Session.Add("UnitNumbers", unitNumbers);
else
Session["UnitNumbers"] = unitNumbers;
// Here is where I want to put the code to open the lightbox, instead of redirecting.
Response.Redirect("../Pages/MaintenanceDetails.aspx");
}
catch (Exception ex)
{
}
}
I have tried using ScriptManager.RegisterStartupScript(GetType(),"hwa","ShowLightBox(param);",true); and it does not find the function.
Any other suggestion?