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

RadAlert box

11 Answers 314 Views
Window
This is a migrated thread and some comments may be shown as answers.
Pravallika
Top achievements
Rank 1
Pravallika asked on 27 Jun 2014, 07:02 AM
HAI  All,


how to write the code when i click on Update button it will show one RadAlert box saved sucessfully if i click on ok button it will redirect to some other page with some id
see this code once 
ASPX:
 
   <cc1:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true" AutoSize="true" CenterIfModal="true" Modal="true">
          </cc1:RadWindowManager>
 
C#:
 
RadWindowManager1.RadAlert("You have Updated the item successfully!", 250, 150, "", "", "");


if i click on "ok" button in radalert it will redirect to some other page like 
 Response.Redirect("ItemDetails.aspx?ItemID={0}", intItemId);

11 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 27 Jun 2014, 08:57 AM
Hi Pravallika,

Please have a look into the sample code snippet to achieve your scenario.

ASPX:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true"
    AutoSize="true" CenterIfModal="true" Modal="true">
</telerik:RadWindowManager>

C#:
RadWindowManager1.RadAlert("You have Updated the item successfully!", 250, 150, "Alert", "callBack");

JavaScript:
function callBack(args) {
    if (args) {
        //here access the ItemId and pass that to the Redirecting page
        window.location = "ItemDetails.aspx?ItemID=2";
    }
}

Thanks,
Shinu.
0
Pravallika
Top achievements
Rank 1
answered on 27 Jun 2014, 09:06 AM
thanks for reply its working fine
0
Pravallika
Top achievements
Rank 1
answered on 27 Jun 2014, 10:07 AM
Hai sir,

i have more than one radbuttons in my code when i click on save button it will display radconfirm box and it have two options "yes" are "no" if i click on yes it will save and it will go to another page if it is No it will stay on that page only and data will not save in the database i need like that i have more than one  button  and for some i need alert box only.in my code i wrote like this
in one aspx page it is not accepting two RadWindowManager s and if i took radconfirm box how i wrote code for two buttons in rbConfirm_OK_Click
function closeCustomConfirm() {
            $find("<%=rw_customConfirm.ClientID %>").close();
          }
 <cc1:RadWindow ID="rw_customConfirm" Modal="true" Behaviors="Close, Move" VisibleStatusbar="false"
            Width="300px" Height="200px" runat="server">
            <ContentTemplate>
                <div class="rwDialogPopup radconfirm">
                    <div class="rwDialogText">
                        <asp:Literal ID="confirmMessage" Text="" runat="server" />
                    </div>
                    <div>
                        <cc1:RadButton runat="server" ID="rbConfirm_OK" Text="OK" OnClick="rbConfirm_OK_Click">
                        </cc1:RadButton>
                        <cc1:RadButton runat="server" ID="rbConfirm_Cancel" Text="Cancel" OnClientClicked="closeCustomConfirm">
                        </cc1:RadButton>
                    </div>
                </div>
            </ContentTemplate>
        </cc1:RadWindow>
 
c#:
 
protected void button1click()
{
    confirmMessage.Text = "Are you sure you want to perform this action?";
            string script = "function f(){radopen(null, 'rw_customConfirm'); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "customConfirmOpener", script, true);
}
 protected void rbConfirm_OK_Click(object sender, EventArgs e)
        {
        ........................
}
0
Shinu
Top achievements
Rank 2
answered on 30 Jun 2014, 04:29 AM
Hi Pravallika,

Please have a look into the sample code snippet which works fine at my end. Please elaborate your requirement if it doesn't help.

ASPX:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true"
    AutoSize="true" CenterIfModal="true" Modal="true">
</telerik:RadWindowManager>
<%--'rbtnShowConfirm' is to show the Confirmation window--%>
<telerik:RadButton ID="rbtnShowConfirm" runat="server" Text="Show Alert" OnClick="rbtnShowConfirm_Click">
</telerik:RadButton>
<%--'rbtnShowAlert' is to show the Alert--%>
<telerik:RadButton ID="rbtnShowAlert" runat="server" Text="Show Alert" OnClick="rbtnShowAlert_Click">
</telerik:RadButton>
<telerik:RadWindow ID="rw_customConfirm" Modal="true" Behaviors="Close, Move" VisibleStatusbar="false" Width="300px" Height="200px" runat="server">
    <ContentTemplate>
        <div class="rwDialogPopup radconfirm">
            <div class="rwDialogText">
                <asp:Literal ID="confirmMessage" Text="" runat="server" />
            </div>
            <div>
                <telerik:RadButton runat="server" ID="rbConfirm_OK" Text="OK" OnClick="rbConfirm_OK_Click">
                </telerik:RadButton>
                <telerik:RadButton runat="server" AutoPostBack="false" ID="rbConfirm_Cancel" Text="Cancel" OnClientClicked="closeCustomConfirm">
                </telerik:RadButton>
            </div>
        </div>
    </ContentTemplate>
</telerik:RadWindow>

C#:
protected void rbtnShowConfirm_Click(object sender, EventArgs e)
{
    //to show the rw_customConfirm window
    string script = "function f(){showWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
}
protected void rbConfirm_OK_Click(object sender, EventArgs e)
{
    //here code for updating the value in database
}
protected void rbtnShowAlert_Click(object sender, EventArgs e)
{
    //to show the Alert box
    RadWindowManager1.RadAlert("Alert Window", 250, 150, "Alert", null);
}

JavaScript:
function closeCustomConfirm() {
    $find("<%=rw_customConfirm.ClientID %>").close();
}
function showWindow() {
    $find("<%=rw_customConfirm.ClientID %>").show();
}

Thanks,
Shinu.
0
Pravallika
Top achievements
Rank 1
answered on 30 Jun 2014, 04:38 AM
It is fine sir but what i need is in "rbConfirm_OK_Click" i have to perform three operations means i have 4buttons if i click on 1sButton it will do some saving operation in one table if i click on 2ndButton it will do some other saving operation in another table so based on button that " rbConfirm_OK_Click" will change so 1st i have to find button in "rbConfirm_OK_Click" if its button1 then do this if it is buuton2 do like this like that i need so how to find buuton in "rbConfirm_OK_Click" operation 
0
Shinu
Top achievements
Rank 2
answered on 01 Jul 2014, 04:20 AM
Hi Pravallika,

I guess you are using 'rbConfirm_OK_Click' event for more than one button and you have to uniquely identify which button is clicked. In  order to achieve that try to mention unique CommandName for each RadButton and in OnClick event write the code based on the CommandName of the Button as follows.

ASPX:
<telerik:RadButton ID="rbtnSaveTable1" runat="server" Text="Save Table1" OnClick="rbConfirm_OK_Click" CommandName="SaveTable1">
</telerik:RadButton>
<telerik:RadButton ID="rbtnSaveTable2" runat="server" Text="Save Table2" OnClick="rbConfirm_OK_Click"CommandName="SaveTable2">
</telerik:RadButton>
<telerik:RadButton runat="server" ID="rbConfirmOK" Text="OK" OnClick="rbConfirm_OK_Click">
</telerik:RadButton>

C#:
protected void rbConfirm_OK_Click(object sender, EventArgs e)
{
    RadButton btn = sender as RadButton;
    if (btn.CommandName == "SaveTable1")
    {
        //here code for updating value in table1
    }
    else if (btn.CommandName == "SaveTable2")
    {
        //here code for updating value in table1
    }
    else
    {
        //your code
    }
}

Please elaborate your requirement if it doesn't help.
Thanks,
Shinu.
0
Pravallika
Top achievements
Rank 1
answered on 01 Jul 2014, 05:00 AM
Hai,
  i am not asking this one see i have 3buttons 
<asp:Button ID="btnTsave"  runat="server" Text="Save as Draft" CommandName="Save" OnClick="btnSaveasDraft_Click" />
                <asp:Button ID="btnConfirm" runat="server" Text="Confirm" CommandName="Confirm" OnClick="btnConfirm_Click" />
                <asp:Button ID="btnApprove" runat="server"  Text="Approve" CommandName="Approve" OnClick="btnApprove_Click" />
 <cc1:RadWindowManager runat="server" ID="RadWindowManager1">
    <Windows>
        <cc1:RadWindow ID="rw_customConfirm" Modal="true" Behaviors="Close, Move" VisibleStatusbar="false"
            Width="300px" Height="200px" runat="server">
            <ContentTemplate>
                <div class="rwDialogPopup radconfirm">
                    <div class="rwDialogText">
                        <asp:Literal ID="confirmMessage" Text="" runat="server" />
                    </div>
                    <div>
                        <cc1:RadButton runat="server" ID="rbConfirm_OK" Text="OK" OnClick="rbConfirm_OK_Click">
                        </cc1:RadButton>
                        <cc1:RadButton runat="server" ID="rbConfirm_Cancel" Text="Cancel" OnClientClicked="closeCustomConfirm">
                        </cc1:RadButton>
                    </div>
                </div>
            </ContentTemplate>
        </cc1:RadWindow>
    </Windows>
</cc1:RadWindowManager>
 
 
C#:
 
protected void btnApprove_Click(object sender, EventArgs e)
        {
             
            confirmMessage.Text = "Are you sure you want to Save this file?";
            string script = "function f(){radopen(null, 'rw_customConfirm');                                    Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
           ScriptManager.RegisterStartupScript(Page, Page.GetType(), "customConfirmOpener", script, true);
        }
protected void btnSaveasDraft_Click(object sender, EventArgs e)
        {
 confirmMessage.Text = "Are you sure you want to Save this file in Draft?";
            string script = "function f(){radopen(null, 'rw_customConfirm');                                    Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
           ScriptManager.RegisterStartupScript(Page, Page.GetType(), "customConfirmOpener", script, true);
}
now what will have after clicking on one button based on button click radconfirm will open now after clicking on "ok" button in RadConfirm  it will perform 3operations means if button1 ok click it will some and if it button2 click it will do some other like that
how to find button id in RadConfirm ok click 
  protected void rbConfirm_OK_Click(object sender, EventArgs e)
        {
            
//here i have two perform 3operations if it save button ok clik it will do some
//if it is Approve button ok click it will do some other
            }
        }

0
Shinu
Top achievements
Rank 2
answered on 02 Jul 2014, 06:24 AM
Hi Pravallika,

One suggestion is try to set a flag variable and on each button click assign a value to the flag. In 'rbConfirm_OK_Click' check the flag value and based on that you can write the code for saving values in table.  Please have a look into the sample code snippet.

ASPX:
<asp:Button ID="btnTsave" runat="server" Text="Save as Draft" CommandName="Save" OnClick="btnSaveasDraft_Click" />
<asp:Button ID="btnConfirm" runat="server" Text="Confirm" CommandName="Confirm" OnClick="btnConfirm_Click" />
<asp:Button ID="btnApprove" runat="server" Text="Approve" CommandName="Approve" OnClick="btnApprove_Click" />
<telerik:RadWindow ID="rw_customConfirm" Modal="true" Behaviors="Close, Move" VisibleStatusbar="false"  Width="300px" Height="200px" runat="server">
    <ContentTemplate>
        <div class="rwDialogPopup radconfirm">
            <div class="rwDialogText">
                <asp:Literal ID="confirmMessage" Text="" runat="server" />
            </div>
            <div>
                <telerik:RadButton runat="server" ID="rbConfirm_OK" Text="OK" OnClick="rbConfirm_OK_Click">
                </telerik:RadButton>
                <telerik:RadButton runat="server" AutoPostBack="false" ID="rbConfirm_Cancel" Text="Cancel" OnClientClicked="closeCustomConfirm">
                </telerik:RadButton>
            </div>
        </div>
    </ContentTemplate>
</telerik:RadWindow>
<asp:Label ID="lblTest" runat="server">
</asp:Label>

C#:
public static int flag = 0;
protected void btnApprove_Click(object sender, EventArgs e)
{
    flag = 1;
    confirmMessage.Text = "Are you sure you want to Save this file?";
    string script = "function f(){showWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
}
protected void btnSaveasDraft_Click(object sender, EventArgs e)
{
    flag = 2;
    confirmMessage.Text = "Are you sure you want to Save this file in Draft?";
    string script = "function f(){showWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
}
protected void btnConfirm_Click(object sender, EventArgs e)
{
    flag = 3;
    confirmMessage.Text = "Are you sure you want to confirm?";
    string script = "function f(){showWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
}
protected void rbConfirm_OK_Click(object sender, EventArgs e)
{
    if (flag == 1)
    {
        lblTest.Text = "btnApprove_Click";
        //write the code base on btnApprove_Click
    }
    else if (flag == 2)
    {
        lblTest.Text = "btnSaveasDraft_Click";
        //write the code base on btnSaveasDraft_Click
    }
    else if (flag == 3)
    {
        lblTest.Text = "btnConfirm_Click";
        //write the code base on btnConfirm_Click
    }
}

JavaScript:
function closeCustomConfirm() {
    $find("<%=rw_customConfirm.ClientID %>").close();
}
function showWindow() {
    $find("<%=rw_customConfirm.ClientID %>").show();
}

Note :The best approach is to show a RadWindow through registering a script from the server. From client side call the show method of the RadWindow.

Thanks,
Shinu.
0
Pravallika
Top achievements
Rank 1
answered on 02 Jul 2014, 06:33 AM
thank you sir it is working fine instead of this i took client side function if it is ok then only it will go to serverside function like this 

<asp:Button ID="btnConfirm" runat="server"  OnClientClick="confirmConfirmButton(this); return false;"   Text="Confirm" ValidationGroup="req1" CssClass="btnSaveForm" OnClick="btnConfirm_Click" />
function confirmConfirmButton(button) {

            function aspButtonCallbackFn(arg) {
                if (arg) {
                    __doPostBack(button.name, "");
                }
            }
            radconfirm("Are you sure you want to Confirm?", aspButtonCallbackFn, 330, 180, null, "Confirm");
        }
0
Pravallika
Top achievements
Rank 1
answered on 02 Jul 2014, 06:41 AM
Hai sir ,

i just want to create one website there i am using telerik controls here in master page i took one division like this your telerik forum site is there like i took one div with black color in that i took 3 divs 1st div is having Radmenu with some radmenuitems in right side i took one label like what you have after login Hi,UserName   what i need is after login in that Hi,Username click i need two items logout and settings how to design  this is my code. i am not getting this design means after clicking on label that division is not looking good 
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
          <script type="text/javascript">
              function OnClientClicked(sender, args) {
  
                  if (args.IsSplitButtonClick() || !sender.get_commandName()) {
                      var currentLocation = $telerik.getBounds(sender.get_element());
                      var contextMenu = $find("<%=RadContextMenu1.ClientID%>");
                         contextMenu.showAt(currentLocation.x, currentLocation.y + currentLocation.height);
                     } else if (sender.get_commandName() == "TransferRight") {
                         transferRight();
                     }
                     else {
                         transferLeft();
                     }
                 }
  
                 function OnClientItemClicked(sender, args) {
                     var itemText = args.get_item().get_text();
                     var splitButton = $find("<%= SplitButton.ClientID %>");
                    if (itemText.toLowerCase() == "transfer right") {
                        transferRight();
                        splitButton.set_text("Transfer Right");
                        splitButton.set_commandName("TransferRight");
                    }
                    else if (itemText.toLowerCase() == "transfer left") {
                        transferLeft();
                        splitButton.set_text("Transfer Left");
                        splitButton.set_commandName("TransferLeft");
                    }
                 }
              </script>
     </telerik:RadCodeBlock>
        
    <asp:ContentPlaceHolder ID="head" runat="server">
         
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server" >
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
        <telerik:RadSkinManager ID="QsfSkinManager" runat="server" Skin="Metro" ShowChooser="false" />
        
        <div runat="server" id="NavBar">
            <div style="display: inline-block; position: absolute; left: 25px; top: 20px;">
                <img src="~/Images/astorShip_transparent.png" width="80" height="20" runat="server" />
            </div>
         
            <div runat="server" style="display: inline-block; position: absolute; left: 125px; top: 0px; border-left: 1px solid #666666;">
                <div id="MegaDropDown">
                    <telerik:RadMenu runat="server" ID="RadMenu1" Skin="Default"
                        Width="880" Height="60" EnableShadows="true">
                        <Items>
                            <telerik:RadMenuItem Text="SETTINGS â–¼" PostBack="false" Selected="false">
                                <ContentTemplate>
                                    <div id="CatWrapper" class="Wrapper" style="width: 100%;">
                                        <div onclick="location.href='UsersList.aspx'">Users</div>
                                        <div onclick="location.href='LocationList.aspx'">
                                            Vessel / Warehouse
                                        </div>
                                    </div>
                                </ContentTemplate>
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="ASSETS  â–¼" PostBack="false">
                                <ContentTemplate>
                                    <div id="CatWrapper" class="Wrapper" style="width: 100%;">
                                        <div onclick="location.href='AssetsOnBoard.aspx'">
                                            Assets on Board
                                        </div>
                                        <div onclick="location.href='AssetTransfer.aspx'">
                                            Transfer Asset
                                        </div>
                                </ContentTemplate>
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="INVENTORY  â–¼" PostBack="false">
                                <ContentTemplate>
                                    <div id="CatWrapper" class="Wrapper" style="width: 100%;">
                                        <div onclick="location.href='InventoryList.aspx'">
                                            Inventory List
                                        </div>
                                        <div onclick="location.href='MaterialRequisitionList.aspx'">
                                            Material
                                            Requisition
                                        </div>
                                    </div>
                                </ContentTemplate>
                            </telerik:RadMenuItem>
                        </Items>
                    </telerik:RadMenu>
                </div>
            </div>
 
            <div id="AnchorRight" >
                <div id="UserIcon">
                   <%-- <asp:ImageButton ID="button" runat="server" ImageUrl="~/Images/user_icon.png"  />--%>
                    <telerik:RadButton  BorderColor="#00006A" ForeColor="White" BackColor="#00006A" ID="SplitButton" AutoPostBack="false"
                    runat="server" Height="50px" Font-Size="Medium" OnClientClicked="OnClientClicked">
               </telerik:RadButton>
                </div>
                <div id="TitleBar">
                           <asp:ContentPlaceHolder ID="TitleContentPlaceHolder" runat="server">
                    </asp:ContentPlaceHolder>
                                    
                </div >
             
            </div>
           
        </div>
         
        <table cellspacing="40" cellpadding="0" width="100%">
            <tr>
                <td>
                    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                    </asp:ContentPlaceHolder>
                </td>
            </tr>
        </table>
        
        <telerik:RadContextMenu
            ID="RadContextMenu1"  runat="server"  OnClientItemClicked="OnClientItemClicked">
                    <Items>
                             <telerik:RadMenuItem PostBack="false" Text="Settings" Selected="false">
                             
                            </telerik:RadMenuItem>
                           <telerik:RadMenuItem PostBack="false" Text="Logout" Selected="false">
                             
                            </telerik:RadMenuItem>
                    </Items>
               </telerik:RadContextMenu>
    </form>
0
Shinu
Top achievements
Rank 2
answered on 22 Jul 2014, 03:50 AM
Hi Pravallika,

The provided code was working fine. Unfortunately I couldn't replicate any issue.

Thanks,
Shinu.
Tags
Window
Asked by
Pravallika
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Pravallika
Top achievements
Rank 1
Share this question
or