Bootstrap Drop Down List Aligning Horizontal - asp.net-mvc

I have three drop down list which includes Days Months and Years for getting birthday from user.
I don't want to put them in a table. I'm trying to work with just Div elements for efficiency.
How can i fix them according to the above textbox ?
The following code is for my registration form
<div class="text-center">
or
</div>
<label>Firstname</label>
<div>
<input type="text" class="form-control" placeholder="Username">
</div>
<label>Lastname</label>
<div>
<input type="text" class="form-control" placeholder="Lastname">
</div>
<label>Email</label>
<div>
<input type="text" class="form-control" placeholder="Email">
</div>
<label>Password</label>
<div>
<input type="text" class="form-control" placeholder="Password">
</div>
<label>Gender</label>
<div>
<select class="form-control">
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
</div><br />
<div class="text-center">
<label>Birthday</label>
<div class="form-inline" role="form">
<div class="form-group">
<div class="input-group">
<select class="form-control" placeholder="Day">
<option value="1">1</option>
<option value="2">2</option>
</select>
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group">
<select class="form-control" placeholder="Month">
<option value="1">January</option>
<option value="2">February</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="input-group">
<select class="form-control" placeholder="Year">
<option value="1950">1950</option>
<option value="1951">1951</option>
</select>
</div>
</div>
</div> <br />
</div>
<div class="text-center">
<input class="btn btn-success" type="submit" value="Register" />
</div>
</div>

Related

parameter not being submitted

The following is an excerpt of a rails form
<%= form_with(model: #usercontent) do |form| %>
where the following html renders a collection
<div class='alert'>
<select class='image-picker show-html' name="ki_id" id="ki_id">
<div class='row'>
<div class='buttonselector'>
<label for="usercontent_ki_id_1">
<input class="invisi-selector" type="radio" value="1" name="usercontent[ki_id]" id="usercontent_ki_id_1" />
<img src='/assets/ki/circle-15-1c2a221aa37a24e5b23acd7124cd47ae2a17434af589353a063633a6ef5abca6.svg'>
<div></div>
</label>
</div>
</div>
<div class='row'>
<div class='buttonselector'>
<label for="usercontent_ki_id_2">
<input class="invisi-selector" type="radio" value="0" name="usercontent[ki_id]" id="usercontent_ki_id_2" />
<img src='/assets/ki/aerialway-15-621960ddf5e9930f1b1102faa4ee23542e11163f48a67470f1fe245abbc27955.svg'>
<div></div>
</label>
</div>
</div>
[...]
</select>
</div>
However, when the user selects an item, the parameter being submitted is "ki_id"=>"0". Where is the above structure wrong?
It is submitted due to name="ki_id" in
<select class='image-picker show-html' name="ki_id" id="ki_id">
Can you show the full code for the view.

How to use the scaffolded LoginModel in another view than Login.cshtml?

I created a dropdown menu to log in instead of logging in at Login.cshtml but i can't seem to be able to use the model that contains the email password etc. I am not sure how to explain this but here is what i made so far:
I created the dropdown form and placed it in _LoginPartial.cshtml so it shows on the navbar
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Log-In
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton" style="width: 300px" >
<!----------->
<div class="col-lg-12">
<div class="text-center">
<h3><b>Log In</b></h3></div>
<form id="ajax-login-form" method="post" role="form" autocomplete="off">
<div class="form-group">
<label for="username">Username</label>
<input type="text" name="username" id="username" tabindex="1" class="form-control" placeholder="Username" value="" autocomplete="off">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="password" id="password" tabindex="2" class="form-control" placeholder="Password" autocomplete="off">
</div>
<div class="form-group">
<div class="col-xs-5">
<input type="submit" name="login-submit" id="login-submit" tabindex="4" class="form-control btn btn-danger" value="Log In">
</div>
</div>
<div class="col-xs-5" align="Center">
<input type="checkbox" tabindex="3" name="remember" id="remember">
<label for="remember"> Remember Me</label>
</div>
<div class="form-group">
<div class="row">
<div class="col-lg-12">
<div class="text-center">
<a tabindex="5" class="forgot-password">Forgot Password?</a>
</div>
</div>
</div>
</div>
</form>
</div>
and after this, i thought i can easily just insert #model loginmodel and i can start using that model but i'm met with so many errors. Any advice on how to do this? I am also open to other approaches too

.NET MVC - adding a radio button with new input

I am new to C# and .NET MVC. I have a View page with a radio button with two options, those are tied to a controller. When I try to add a new radiobutton by copying the radio button code in the View page, the newly added radiobuttons act like a continuation of the existing radiobuttons with the same input. I would like to differentate both radio buttons and use the input from the newly added radiobuttons elsewhere. Parts from my controller and Viewpage are below. Please ask me if you need more information.
Viewpage:
<div class="form-group">
<div class="control-label col-md-2"></div>
<div class="col-md-10">
<div class="clearfix">
<div class="pull-left inline-radio">
<input type="radio" name="radiobtn" value="1" class="clsradio" />
<label for="radiobtn">#kisanResources.App_GlobalResources.ResourceProductionMaterial.locale</label>
</div>
<div class="pull-left inline-radio">
<input type="radio" name="radiobtn" value="2" class="clsradio" />
<label for="radiobtn">#kisanResources.App_GlobalResources.ResourceProductionMaterial.foreign</label>
</div>
</div>
</div>
</div>
// ....
<div class="form-group">
<div class="control-label col-md-2"></div>
<div class="col-md-10">
<div class="clearfix">
<div class="pull-left inline-radio">
<input type="radio" name="radiobtn" value="3" class="clsradio" />
<label for="radiobtn">#kisanResources.App_GlobalResources.ResourceProductionMaterial.locale</label>
</div>
<div class="pull-left inline-radio">
<input type="radio" name="radiobtn" value="4" class="clsradio" />
<label for="radiobtn">#kisanResources.App_GlobalResources.ResourceProductionMaterial.foreign</label>
</div>
</div>
</div>
</div>
When I add the second radiobutton with values 3 and 4, I want it to be treated as a different input, not the same as the first radiobutton.
Can you help me with this?
Thanks!
You will need to give the second radio button a different name, so in the below code I have given it the name="radiobtn2"
<div class="clearfix">
<div class="pull-left inline-radio">
<input type="radio" name="radiobtn" value="1" class="clsradio" />
<label for="radiobtn">#kisanResources.App_GlobalResources.ResourceProductionMaterial.locale</label>
</div>
<div class="pull-left inline-radio">
<input type="radio" name="radiobtn2" value="2" class="clsradio" />
<label for="radiobtn">#kisanResources.App_GlobalResources.ResourceProductionMaterial.foreign</label>
</div>
</div>
So within a form no two radio buttons should have the same name attribute if you want them to perform different actions.
I would also suggest reading id vs. name
Try this solution , it should fix your problem, it seems you are referring two different ratio buttons with same name radiobtn. that is causing issue.
Here i updated two radio buttons names like
<input type="radio" name="radiobtnFirst" value="3" class="clsradio" />
<input type="radio" name="radiobtnSecond" value="4" class="clsradio" />
Complete Form:
<div class="form-group">
<div class="control-label col-md-2"></div>
<div class="col-md-10">
<div class="clearfix">
<div class="pull-left inline-radio">
<input type="radio" name="radiobtn" value="1" class="clsradio" />
<label for="radiobtn">#kisanResources.App_GlobalResources.ResourceProductionMaterial.locale</label>
</div>
<div class="pull-left inline-radio">
<input type="radio" name="radiobtn" value="2" class="clsradio" />
<label for="radiobtn">#kisanResources.App_GlobalResources.ResourceProductionMaterial.foreign</label>
</div>
</div>
</div>
</div>
// ....
<div class="form-group">
<div class="control-label col-md-2"></div>
<div class="col-md-10">
<div class="clearfix">
<div class="pull-left inline-radio">
<input type="radio" name="radiobtnFirst" value="3" class="clsradio" />
<label for="radiobtn">#kisanResources.App_GlobalResources.ResourceProductionMaterial.locale</label>
</div>
<div class="pull-left inline-radio">
<input type="radio" name="radiobtnSecond" value="4" class="clsradio" />
<label for="radiobtn">#kisanResources.App_GlobalResources.ResourceProductionMaterial.foreign</label>
</div>
</div>
</div>
</div>

File upload formatting in Bootstrap MVC

I have this in an MVC view
<form id="fileupload" action="#Url.Action("Save")" method="POST" enctype="multipart/form-data">
<div class="container">
<div class="row">
<div class="form-group">
<label for="datepicker1">Invoice Date</label>
<div class='bfh-datepicker' id='datepickerDiv'>
<input type='text' id="datepicker1" class="form-control" />
</div>
</div>
<div class="form-group">
<label for="InvoiceNumberTB">Invoice Number</label>
<input type="text" class="form-control" id="InvoiceNumberTB" />
</div>
<div class="form-group">
<label for="NetAmountTB">Net Amount</label>
<input type="text" id="NetAmountTB" class="form-control text-right" placeholder="0.00" />
</div>
<div class="form-group">
<label for="TaxAmountTB">Sales Tax</label>
<input type="text" id="TaxAmountTB" class="form-control text-right" placeholder="0.00" />
</div>
<div class="form-group">
<label for="InvoiceTotalTB">Invoice Total</label>
<input type="text" id="InvoiceTotalTB" class="form-control text-right" placeholder="0.00" />
</div>
<div class="form-group">
<label for="InvoiceDescriptionTB">Description</label>
<input type="text" id="InvoiceDescriptionTB" class="form-control" />
</div>
<div class="form-group">
<label for="DocumentUploadTB">Optional - Upload Invoice (PDF)</label>
<span class="btn btn-success fileinput-button">
<span>Add File...</span>
<input type="file" id="DocumentUploadTB" class="form-control" />
</span>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-plus-sign"></span> Save</button>
</div>
</div>
</div>
But the label for the file upload is not formatting as I would have hoped (at the top of the field as the others) but looks like this
Could someone point me in the correct direction?
Thanks
Wrap the content after the label in a form-control-static div and lose the form-control class on the input:
<div class="form-group">
<label for="DocumentUploadTB">Optional - Upload Invoice (PDF)</label>
<div class="form-control-static">
<span class="btn btn-success fileinput-button">
<span>Add File...</span>
<input type="file" id="DocumentUploadTB" />
</span>
</div>
</div>
You want your btn span to display as a block element. Try adding a display: block; style to it, or use a simple bootstrap utility class like .show:
<div class="form-group">
<label for="DocumentUploadTB">Optional - Upload Invoice (PDF)</label>
<span class="btn btn-success fileinput-button show">
<span>Add File...</span>
<input type="file" id="DocumentUploadTB" class="form-control" />
</span>
</div>
Example: http://codepen.io/kspearrin/pen/PqpgYq

ASP.Net MVC 4 C# login form with PhantomJS and Selenium

I have a specific question, as i can't figure out how to submit form without "id" or "name" in selenium.webdriver (phantomjs) there is html logim form:
<div class="ui-helper-child-2 ui-page-column-last ui-page-column-span-12">
<div class="ui-page-column-block ui-widget-signin">
<h1>Sign In</h1>
<form action="/glo/en-us/session,create/view.html" method="post">
<div class="ui-helper-child-1">
<label class="ui-state-required" for="username">Customer ID:</label>
<input id="username" name="username" maxlength="9" type="text" value="" />
</div>
<div class="ui-helper-child-2">
<label class="ui-state-required" for="password">Password:</label>
<input id="password" name="password" maxlength="20" type="password" value="" />
</div>
<div class="ui-helper-child-3">
<label class="ui-state-required" for="companyId">Company:</label>
<select id="companyId" name="companyId">
<option selected="selected" value="glo">Choose company</option>
<option value="asp">new to asp</option>
<option value="aeg">who is it</option>
<option value="asus">who use this brand name</option>
</select>
</div>
<div class="ui-helper-child-4">
<input id="callback" name="callback" type="hidden" value="/glo/en-us/home,show/view.html?error=1" />
<input type="submit" value="Sign In" />
</div>
</form>
</div>
and one more time how to login? I can add information to by webdriver.FindElement(username) and so on, but not know how to post data as i don't have id or name in submit element.
I think this will work for you:
driver.FindElement(By.CssSelector(".ui-helper-child-4>[type='submit']")).Click();

Resources