i've two groups of radio buttons, a drop down list & a submit button..on corresponding selected radio buttons & drop down item i need to open next specific form..
say if i selected in first radio button say Existing user(of website) and in another say individual, and in drop down if i select residential property then it should open a residential form,if i select commercial property then it should open a commercial form etc.
can u please help me out??
I assume there is button and on click of this button you have open either of the forms.. You can add a Button_Click() event handler and in there check
Psuedo-code looks like this
if(radioButton1.selected && dropdownList.SelectedValue =="Residential")
{
frmResidential frmRes = new frmResidential();
frmRes.Show();
}
Code example in previous post will work for window forms. Looks like you have Web Application. In this case you can use Response.Redirect method to go to different web form.
if(radioButton1.selected && dropdownList.SelectedValue =="Residential")
{
Response.Redirect("YouPage.aspx");
}
Related
So in my Windows forms application (C#) i have a grid of button elements (btn0, btn1, ... , btn200) . I've been looking around for some time now but I couldn't find the answer I was looking for.
The question is how can I change the property of all the button at the same time.
At first I tried formatting a string like this: "btn" + id, (the id being the button number) so that I would have every button name in a string. But then I had a problem changing from string to button (type). Is there a way to do that ?
The other thing I tried to do was to create an array of buttons, but haven't had success with that either.
Is one of those two ways possible and how?
Assume that the buttons are all in a control named parent:
foreach(Button btn in parent.Controls.OfType<Button>())
{
// do something with btn
// eg btn.Text = "New Text";
}
If the buttons are directly in the form, use this instead of parent. If the buttons are in some kind of a panel, use panelName instead of parent.
The above works because as you stated, all the buttons share the same parent. However, if in some other scenario you have buttons in different parents (say panels), you would then need to do some recursion or specify multiple specific parents to loop on).
You can find it by
Controls.Find("btn1", true);
Where btn1 is the name of the button (the string you generated)
FIrst of all why don't you use an array or List of buttons in place of button1,button2.
Button[] buttons=new Button[size];
....................
button[i].Property="value";
If you don't want to change then other option would be to use a linq query on Form.Controls like this,
var buttons = from button in Controls.OfType<Button>() where
button.Name.StartsWith("btn") select button ;
This will give you list of all buttons that matches your pattern.
or use "button.Name=="btn" + id" to get the exact button you are looking for.
var buttons = from button in Controls.OfType<Button>() where
button.Name=="btn"+id select button ;
I have a form which includes AdobeShockwave player for play some YouTube videos by clicking on the different buttons.
I've set a comboBox (This allow user to choose what events need to show it in the AdobeShockwave) and 3 Radio buttons (for see the rest of the buttons and videos).
I've already put codes in the Visual Studio and compiled and it was true.
But i have a problem.
Just imagine i put some codes which includes : when user choose number one in the combobox (index 1) and then choose the radio button, Set the Text of Buttons.
But now i wanna do something and put some codes which includes, When user choose button 1 , specific video show in the Shockwave and when user click on the button 2, Show the specific video and ... .
I know i have to put this code in the Button event :
if (comboBox1.SelectedIndex == 1)
axShockwaveFlash.Movie = "Video's URL";
But i code above happen if :
1. ComboBox1.SelectedIndex == 1
2. RadioButton1.Checked = true
3.Then when user click in the button 1 Show the video.
I put my image which can help you.
Thanks in advance for your Help.
And these are my codes :
private void radioPage1_CheckedChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex == 1)
{
/* Show/Display the numbers of row in the form*/
lbl1.Show();
btn1.Show();
/* Change the label of the Events*/
lblEvents.Text = "StarCraft II ProLeague 2016 S1 :";
}
Update
There is no one to answer my problem ?
Internet Explorer is open and it is showing a webpage. We know there a drop down and a textbox and a button are exist in this page.
I need to select an item from drop down, writing a text in textBox and clicking on that button.
How Can I do these using WatiN by pressing on a button in windows form, I currently add its related libraries and I have add WatiN.Core in using section, but it seems it is not working with windows forms.
This is a very small example but not sure what you mean by "not working" (does it throw an exception, are you able to start the program, when you click the button it fails, you need to be more precise on this).
using(var ie = new IE){
ie.GoTo("http://www.yourwebpage.com");
TextField entry = ie.TextField(Find.ById("myEntryBox"));
Button btn = ie.Button(Find.ById("submit"));
SelectList menu = ie.SelectList(Find.ById("selectList"));
entry.Value ="Hello world");
menu.SelectByValue("2");
btn.Click();
}
if you are having other problems, please, let us know.
I have a purchases form that requires you to select a customer ID, currently it is just a dropdown list of Customer Names with their ID hidden.
What I want to do is instead of a dropdown list, there will be a hyperlinked select button that when clicked will open a popup box that allows them to search through a list of customers using whatever field they choose.
Now I have had no problem with making the popup box search through for a customer, I just don't know how to pass that data back to the main page. Are there any examples for this?
There are some ways to send data from popup window to opener window:
1) use window.opener property in popup window:
function pick(data) {
if (window.opener && !window.opener.closed)
window.opener.document.anyForm.anyInput.value = data;
window.close();
}
2) More exotic: use local storage to handle custom events from other window
look at sample
here's my page's life story
first: there's a button (linkButton if that matters) and its onClick action-1 (event set in Page_Load)
that action makes a panel get visible
the now-visible panel contains not-Dynamic controls ; a button and its onclick action-2
action-2 adds the dynamic controls (table&row&cell ,radioButtonList )
what I wanted to do is to get the selected item of each radioButtonList that has been generated !!
and here's what I tried doing :
tryout-1 {radioButtonList1.SelectedIndexChanged += new EventHandler (function);} ->failed , I don't know why event won't fire!!!
tryout-2 {
foreach (Control x in radioButtonList1.Controls)
{RadioButton one = (RadioButton)x;
one.CheckedChanged += new Eventhandler(function);} -> failed .. won't fire O.o
}
tryout-3 I added a button(plus onClick event) along with each radioButtonList so I can get the selected item when the button is clicked .. but it failed as well ; when the button is clicked the dynamically created controls are gone
I know there's "IsPostBack"thing , but as far as I know it should be in Page_Load|Init and my controls are generated in an event action !! am I mistaken??
and now after more than 2 days of work I'm still in square 1 , and I ran out of games to play around this
any idea what to do ?!
PS : I did the story-like post cuz I don't know what code to post .. it's mostly objects declaration !! so, if u need a particular piece of code let me know and I'll post it
thank you
You must set PostBack to true for radio button.