In codebehind of my asp.net page has a button and when single-click her open a RadWindow, don't have a problem.
The problem is when somebody close the radwindows, because to open is necessary double-click. I don't like this.
For me control refresh to disable the double-click page I use:
Boolean IsPageRefresh;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["postids"] = System.Guid.NewGuid().ToString();
Session["postid"] = ViewState["postids"].ToString();
}
else
{
if (ViewState["postids"].ToString() != Session["postid"].ToString())
{
IsPageRefresh = true;
}
Session["postid"] = System.Guid.NewGuid().ToString();
ViewState["postids"] = Session["postid"].ToString();
}
}
But don't work, somebody use F5 or click in button the radwindow open again.
How can I detect to difference when use F5 and Click button?
Related
I making a wpf application but in settings window, I'm changing the text of textboxes listed in view, then I click save
button to update Properties.Settings.Default. Then, I close settings window. I go back to the MainWindow. But when I shutdown the application, in the next session my values does not show up. How could I solve it?
Save Button:
private void save_Click(object sender, RoutedEventArgs e)
{
Properties.Settings.Default.PC_Name = pcname.Text;
Properties.Settings.Default.Acc_name = name.Text;
Properties.Settings.Default.Acc_sname = sname.Text;
}
Loaded Event(Page):
private void ayarlarekrani_Loaded(object sender, RoutedEventArgs e)
{
pcname.Text = Properties.Settings.Default.PC_Name;
name.Text = Properties.Settings.Default.Acc_name;
sname.Text= Properties.Settings.Default.Acc_sname;
}
Looks like you are missing:
Properties.Settings.Default.Save();
http://learn.microsoft.com/en-us/dotnet/framework/winforms/advanced/how-to-write-user-settings-at-run-time-with-csharp
I am working on a C# project using asp framework 4.5 and I am having this problem :
I want a way to avoid a resubmission of the form on page refresh (without self redirect):
When refreshing the page, the button does trigger itself, I need to avoid the second submission without page redirection .
I am trying to upload a file, on the first try every thing is Working fine, but, when I hit f5 to refresh the page, the form will be resubmitted.
try below code
public bool IsPageRefresh = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["postids"] = System.Guid.NewGuid().ToString();
Session["postid"] = ViewState["postids"].ToString();
}
else
{
if (ViewState["postids"].ToString() != Session["postid"].ToString())
{
IsPageRefresh = true;
}
Session["postid"] = System.Guid.NewGuid().ToString();
ViewState["postids"] = Session["postid"].ToString();
}
}
just check below condition on button click
if (!IsPageRefresh)
{
// write you post code
}
try this it's working perfect for me .
I am working on asp.net project. I have a search textbox in it. when I search first time it work properly. Then after refresh the page textbox value is not clearing.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
txtEmployeeID.Text = string.Empty;
}
txtEmployeeID.Focus();
}
If you are just refreshing by pressing F5 or Ctrl + R then it is considered as just a page refresh.
There is a difference in refresh and a postback.
Please refer the below article
http://www.codeproject.com/Articles/68371/Detecting-Refresh-or-Postback-in-ASP-NET
try this code
in your mark up set autopostback in your textbox as true
protected void Page_Load(object sender, EventArgs e)
{
if(Page.IsPostBack)
{
txtEmployeeID.Text = string.Empty;
}
txtEmployeeID.Focus();
}
just remove "!" in your if statement, or remove the if statement.
I have 2 pages (Home and Сategory)
Load page Home on there's button. Click button run panel RadWindow (NavigateUrl: Сategory).
protected void ShowWindow()
{
string script = "function f(){$find(\"" + RadWindow_editor.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
}
protected void RadButtonEdit_Click(object sender, EventArgs e)
{
ShowWindow();
}
Load RadWindow NavigateUrl - Сategory on there's button. Click button close RadWindow.
protected void RadButtonEdit_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "Close();", true);
}
function GetRadWindow() {
var oWindow = null;
if (window.radWindow)
oWindow = window.radWindow;
else if (window.frameElement.radWindow)
oWindow = window.frameElement.radWindow;
return oWindow;
}
function Close() {
var oWindow = GetRadWindow();
oWindow.argument = null;
oWindow.close();
return false;
}
How to refresh the page Home? (Click button close RadWindow)
Thank you!
Here's how: http://www.telerik.com/community/forums/aspnet-ajax/window/how-to-refresh-the-page-click-button-close-radwindow.aspx#2894238.
If your page does not refresh, then the problem is in the page. Having a has in the URL can cause this problem. Make sure you change the URL so you have a fresh GET request.
There are client-side events like OnClientBeforeClose and OnClientClose.
http://demos.telerik.com/aspnet-ajax/window/examples/clientsideevents/defaultcs.aspx
and check this link, it gives you an idea.
How to close the radwindow on serverside and refresh the parent page
You should also look at using a RadAjaxManager in the parent page to send the window events to the parent as shown in the the following demo: Grid and Window. It focuses on refreshing a grid, not a page in your instance, but the concept of sending events to the parent page remains the same.
I am using the below code in visual studio to make an auto login software . The software is working fine, But the page that is displayed after login has a popup script. This forces the opening of popup url in internet explorer. I want to block the internet explorer getting opened. Can i solve this ?
private void webBrowser1_DocumentCompleted_1(object sender, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser1.Navigate("https://mwcp-ekm-04.adlkerala.com:8001/");
webBrowser1.Document.GetElementById("name").InnerText = "name";
webBrowser1.Document.GetElementById("id").InnerText = "66491";
webBrowser1.Document.GetElementById("accept").InvokeMember("click");
}
You can prevent the opening of a new window (popup) by subscribing to the NewWindow event and then cancel the event itself:
private void webBrowser1_NewWindow(object sender, CancelEventArgs e)
{
e.Cancel = true;
}