How to open a new window not in the same new window? - c#

How to open a new window not in the same new window?
The following code can open a new window However after pressing button again
the content will be replaced. How to open the next or next next content in a new window not in the same new window
string strPop = "<script language='javascript'>" +
"window.open('viewpage.aspx?type=3&start=" + txtStartDate.Text + "&end=" + txtEndDate.Text + "','Report');" +
"</script>";
Page.RegisterStartupScript("Pop", strPop);

Replace the window name 'Report' with '_blank' or generate a unique window name instead of the static 'Report' name.

Always give the new windows new names and they'll open in separate windows

Related

WPF Secondary window snapshots main window

An WPF project has a MainWindow holding multiple books (in this case just one).
The pencil icon is in fact a button creating a new instance of the BookEdit window and showing it. Clicking it should show the following (and it used to do so).
My issue is that recently, the secondary window starts snapshotting the mainwindow and showing a portion of it as part of the window:
and it keeps doing so even when I move the window:
Why does that happen? Is it an issue with my GPU/whatever? I cannot currently test the software on another device.
I also removed any ZIndex from the solution.
Edit 1:
It should be noted that the books from MainWindow are generated behind using Children.Add
Button newbutt = new Button();
newbutt.Background = null;
newbutt.SetResourceReference(Control.StyleProperty, "BookToolbarButton");
newbutt.Click += new RoutedEventHandler(FileHandler.editBook);
Image pencil = new Image();
pencil.Source = new BitmapImage(new Uri("pack://application:,,,/Images/pencil.png"));
newbutt.Content = pencil;
sp.Children.Add(newbutt);
editBook():
string name = (((sender as Button).Parent as StackPanel).Parent as Grid).Name;
if (System.String.IsNullOrEmpty(name)) Console.WriteLine("Error: The book does not hold a ");
else
{
Console.WriteLine("Editting book {0}", name);
BookEdit bEdit = new BookEdit("books/" + name + ".json");
bEdit.Show();
}

String variable clears after loading another form?

I have two forms, create order and display order. Once the confirm order button has been pressed on CO form, the products are stored into a string variable
productsPlaced = Convert.ToString(textBox1.Text + Environment.NewLine + textBox2.Text);
Upon confirming the order, console.writeline shows the data still in the variable.
Upon opening DO form the variable clears and console.writeline shows nothing.
I am trying to display this variable data into another textbox on a different form.
textBox1.Text = createOrder.productsPlaced;
Any ideas?
Thanks
You could Declare a Static variable in Form
public static string productsPlaced = null;
productsPlaced = textBox1.Text + Environment.NewLine + textBox2.Text;
In 2nd Form:
tBox1.Text = createOrder.productsPlaced;

Keeping saved data in tab when navigating between tabs

I have a program where you can enter data into text boxes in a tab control, then save the information you enter for later use. I have an 'Add tab' button, so I can add new tabs and enter new data, unfortunately when I click on the new tab and then go back to the previous tab my saved data in the previous tab has disappeared.
When I close the program and re run it, my data is there again, it is only when I navigate between tabs that my tab data disappears.
How do I make sure my data stays saved when I navigate between tabs?
Here is my add tab button code to give you a better understanding
int seasonYear = 12;
TabPage newTP = new TabPage();
tabControl1.TabPages.Add(newTP)
int TabPageNumber = tabControl1.SelectedIndex + 1; // +1 one up from current
tabControl1.TabPages[TabPageNumber].Text = "Season " + (12 - TabPageNumber);
txtPosition.Clear();
txtPoints.Clear();
txtWon.Clear();
txtDrawn.Clear();
txtLost.Clear();
tabControl1.SelectTab(TabPageNumber);
btnRemovetab.Enabled = true; // We now have something to delete
panel1.Parent = tabControl1.SelectedTab;
ShowData();
}

How do I add a tab to a given tabcontrol.?

I am using VS2010 (C#) and I want to create a button that creates a new tab. I already have a tabControl container created. How would I do this?
Moved here from Brandon's solution in the question:
string title = "TabPage " + (tabControl1.TabCount + 1).ToString();
TabPage myTabPage = new TabPage(title);
tabControl1.TabPages.Add(myTabPage);

TabControl create one like a browser

I am working on a web browser project I want to make a web browser I used ToolStrip to put all the functions of the web browser(favorite, history, home, GO, back, forward). What I want now is to make tha Tabs.
1) what do you think the best way to implement the tabs is it TabControl or is there another way.
2) how do I make to click on a label next to each tab and I open the new tab with a label next to it. So I can open a third one and so on.
I found this code, but it does not add dynamically and it add the second tab with leaving the label on the first tab
this.tabControl1.SelectedTab = tabPage2;
1) i made a tabcontrol and deleted all the tabs in the form
2)i made a button look like a plus and one looks like a minus and added this code:
int Counter = 1;
this.tabControl1.TabPages.Add("Page " + Counter);
this.tabControl1.SelectTab(Counter - 1);
Counter = Counter + 1;
this will add a new tab with title page (1,2,3,4,..,n) and then i put a code when i press go to the specified Url:
RequestAndResponsHelper RS = new RequestAndResponsHelper(Url.Text);
StringBuilder s = new StringBuilder();
s = RS.GetRequest();//get the request from a different class
string HtmlString = s.ToString();
rtb = new RichTextBox();
rtb.AppendText(HtmlString);
rtb.Name = "RichText";
rtb.Dock = DockStyle.Fill;
this.tabControl1.SelectedTab.Controls.Add(rtb);

Categories