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

Open RadWindow on Button Click Event

6 Answers 494 Views
Window
This is a migrated thread and some comments may be shown as answers.
Asa'ad
Top achievements
Rank 1
Asa'ad asked on 08 Jun 2011, 09:21 AM
Dear All,

i have a simple form which is used to login the user to the web application i develop,

i want to show messages to users in case their username and password are incorrect.

i want to use the radWindow control.

i put the following code on my login button click event
.....
......
after user name and paswword validating
if(false){

Telerik.Web.UI.

 

RadWindow newWindow = new Telerik.Web.UI.RadWindow

();

 

 

 

newWindow.NavigateUrl =

 

 

 

"My Message Form name"

;

 

 

 

newWindow.OpenerElementID = btnLogin.ClientID;

newWindow.VisibleOnPageLoad =

 

true

;

 

 

 

newWindow.DestroyOnClose =

 

 

 

true

;

 

 

 

RadWindowManager1.Windows.Add(newWindow);


}

this works fine when click the button by the user...
but if the page is reloaded/refreshed the window is opened again and again...
i don't wont this to happen..
how to prevent the rad window to show if the page is refreshed?


Hope you can help me....

Thanks

Best Regards

6 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 08 Jun 2011, 02:31 PM

Hi Asa'ad,

When a RadWindow is declared in RadWindowManager it preserves its ViewState which may lead to this unexpected result when the VisibleOnPageLoad property is used with the idea to show the RadWindow only once. Possible solutions for this case are the following ones: 

  • Set EnableViewState = "false" for the RadWindowManager
  • Reset the VisibleOnPageLoad property to false with code when suitable, depending on the particular scenario 
  • Show the RadWindow through registering a script from the server instead (see the this blog post for more information on the matter).

I hope this helps.

Regards,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Asa'ad
Top achievements
Rank 1
answered on 12 Jun 2011, 09:01 AM
Thank you marin

i tried to call the window or alert from code behind using the RadAjaxManager as the following example and it worked for me very well...


 

 

protected void btnOk_Click(object sender, EventArgs e)

 

 

{


RadAjaxManager1.ResponseScripts.Add(

 

@"radalert('Welcome to RadWindow <b>Prometheus</b>!', 330, 210);");

 


}

thank you again...
0
Phil
Top achievements
Rank 1
answered on 30 Jul 2011, 09:15 PM
I added a line of code to reset the window in

[WindowName].Windows.Clear(); in the pageload.
Seemed to work, which I thought was a little strange. I was anticipating that I would need to include a trap in the pageload function so that when the button was clicked the [WindowName].Windows.Clear();  line would be bypassed. For some reason my code works without the trap

Phil

0
Kanna
Top achievements
Rank 2
answered on 15 Dec 2011, 04:14 AM
This (Asa'ads) code is not working for me. Is there any other properties need to set to my asp button?
Is there any other way to display an alert box using relerik controls from code behind in asp.net??
If yes, please help me out.

Thanks,
Santhosh Kumar Gudise
0
Princy
Top achievements
Rank 2
answered on 15 Dec 2011, 06:00 AM
Hello,

Try the following code snippet to open an alert box on button click.
CS:
protected void Button1_Click(object sender, EventArgs e)
  {
      RadWindowManager windowManager = FindControl(this, "WindowManager") as RadWindowManager;
   windowManager.RadAlert("MessageText", 400, null, "title", null);                  
  }
Note:Make sure you have RadWindowManager on page.

Thanks,
Princy.
0
Kanna
Top achievements
Rank 2
answered on 16 Dec 2011, 04:36 AM
Hi,
Here is an easy way to implement alert, prompt,confirm boxes.

I'm displaying the radAlert box from code behind by using below code and it is working fine for me and easy to implement.

In aspx,
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true" />
 <asp:Button ID="btnRadAlert1" Text="Show Alert" runat="server" OnClick="btnRadAlert1_Click" />

In aspx.cs:
protected void btnRadAlert1_Click(object sender, EventArgs e)
        {
            RadWindowManager1.RadAlert("Successfully created", 200, 100, "Message", null);
            //Like wise u can display confirm, prompt boxes also.
}

Hope it might be useful for anyone..!!

Thanks n Regards,
Santhosh Kumar Gudise
Tags
Window
Asked by
Asa'ad
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Asa'ad
Top achievements
Rank 1
Phil
Top achievements
Rank 1
Kanna
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Share this question
or