Can't use #ViewBag inside #Html.textbox? - asp.net-mvc-3

I want to set the value of a text box to a ViewBag item. Why doesn't the code below work?
#Html.TextBox("UName", #ViewBag.UName)

#Html.TextBox("UName", (string)ViewBag.UName)

Related

how to call SetExtendedUI on CMFCToolBarFontComboBox

I am creating a MFC application based on example: https://github.com/microsoft/VCSamples/tree/master/VC2010Samples/MFC/Visual%20C%2B%2B%202008%20Feature%20Pack/WordPad
now i want to change the way to expand font name drop list in toolbar from DOWN key to F4. It seems i need to get the combobox and call SetExtenedUI(FALSE) on it, but i dont know where to do it.
To change the extended UI flag on a CComboBox, you call its CComboBox::SetExtendedUI member. When you have a CMFCToolBarFontComboBox you need to get to its combo box first. Since it inherits from CMFCToolBarComboBoxButton you can use its CMFCToolBarComboBoxButton::GetComboBox member to get a CComboBox*.
CMFCToolBarFontComboBox* pFontButton = ...;
CComboBox* pComboBox = pFontButton->GetComboBox();
pComboBox->SetExtendedUI(FALSE);
finally i switched to CComboBoxEx which works fine

Set option selection on mat-select to return placeholder after selection

I have the following Angular 6 code:
https://stackblitz.com/edit/angular-pl9wkw
I'm tryin g to make the select dropdown reset to the place holder once a selection has been made. I am using these two lines to try and reference the process:
#ViewChild('selectDropdown') selectDropdown: MatSelect;
and
this.selectDropdown.AppComponent.reset();
Alas, it does not work to set the dropdown back to the placeholder. I know that it can be set back to the placeholder, because I have the blank <mat-option></mat-option> selectable, and once you do select it, it sets it back to the placeholder.
Any thoughts ... anyone.
In your onChange method make the following change.
this.selectDropdown.value = [];
// this.selectDropdown.AppComponent.reset();
In your Onchange make following change
this.selectDropdown.value.reset();

Cannot access .text in a VF9 textbox

I have a very simple form with a text box to enter the year wanted, and a "GO" button. However, the textbox will only display the textbox name ("GETYEAR"). I cannot change it in either the properties nor when I run the project. If I reference GETYEAR.TEXT I get an error that it doesn't exist. I thought it should work the same way as in VB. Can anyone help me with why the textbox is/seems locked ?
Thank you.
In vfp textbox.text property is readonly you cannot change it. Use thisform.getyear.value property instead. I think it will work

Html.Display does not work with ViewBag

Html.Display does not work with ViewBag.
#Html.Display("disp", (string)#ViewBag.disp)
I must use this viewbag because it can be modified by a search button selecting another disp.
#Html.TextBox("disp", (string)#ViewBag.disp)
If I use TextBox instead of Display it works, but I want to be read-only. How it is possible?
Because there's no overload of Display which takes a value as argument.
So.
You can simply do
#ViewBag.disp
or (if it contains HTMl)
#Html.Raw(ViewBag.disp)
or if you want a TextBox
#Html.TextBox("disp", (string)#ViewBag.disp, new{#readonly = true})

Is there a way to select a child element inside another child element in Watin

I am trying to select a link/button inside of a form, that is in a div. the way it was made is that there are two links/buttons of the same id, name etc. however they are in different forms, so the code i wanted to use is:
_myTest.Form(Find.ById("PermissionsForm")).Child(Find.ByClass("saveBtn")).Child(Find.ByText("SAVE"));
any help would be appreciated
I think this is what you need:
var button = _myTest.Form("PermissionsForm").Button(Find.ByClass("saveBtn"));
This will lookup the button having the class 'saveBtn' inside the form 'permissionsform' in your browser instance _myTest.
Have a look at this page to decide if you need to have .Button(..) or .Link(...) based on the html tag that is used in your html.
How about building a regex for the element?
Regex could something like this
Regex elementRe = new Regex("id=LnkOk href="http://stackoverflow.com");
Then you can use your code to Click this link. The Click method can be extended to accept Regex if it is not already doing that.
Let me know how this goes or if you need more info.
Cheers,
DM

Resources