Editing Row using KendoGrid - asp.net

Hi I am Having a View Where I am using Kendo Grid.I am editing the row of the table but getting the error.Here is my Code goes.
#(Html.Kendo().Grid<Invoice.Models.ViewModels.Setup.AccountViewModel>()
.Name("Account")
.Columns(columns =>
{
columns.Bound(p => p.AccountID).Title("ID").Width(250);
columns.Bound(p => p.AccountType).Title("Account Type").Width(225);
columns.Bound(p => p.AccountName).Title("Account Name").Width(225);
columns.Bound(p => p.Currency).Title("Currency").Width(225);
columns.Bound(p => p.Status).ClientTemplate("#=data.Status#").Width(225).HtmlAttributes(new {style="text-align:center"});
//columns.Command(command => command.Custom("Edit").Click("showDetails")).Title("Action").Width(150);
columns.Command(command => { command.Edit();}).Width(90);
})
.ToolBar(toolbar =>
{
toolbar.Template(#<text>
<div class="row-fluid">
<div class="span1">
<div class="toolbar" style="height:25px;">
<ul id="menu" style="width:38px; margin-left:22px;" class="span6">
<li style="width:36px;">
<i class="fa fa-plus"></i>
<ul>
#foreach (var account in #ViewBag.AccountType)
{
<li style="width:100px;" class="openid">
#if (#account.Value == "Bank")
{
<label id="Bank1">#account.Value</label>
}
#if (#account.Value == "CreditCard")
{
<label id="Credit">#account.Value</label>
}
#if (#account.Value == "Cash")
{
<label id="Cash1">#account.Value</label>
}
</li>
}
</ul>
</li>
</ul>
</div>
</div>
</div>
</text>);
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.HtmlAttributes(new { style = "height:550px;" })
//.Selectable(selectable => selectable
//.Mode(GridSelectionMode.Multiple))
.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("UpdateAccount"))
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
//.ServerOperation(true)
.Model(model => model.Id(p => p.AccountID))
.Read(read => read.Action("Account_Read", "Setup"))
.Create(c => c.Action("Account_Create", "Setup"))
.Update(u => u.Action("Account_Update","Setup"))
)
)
Now the thing is that I am fetching the "Status" from the database that is a HTML tag <span class="label label-success">Active</span> and converting this into the label As Active,InActive and Blocked and Displaying it into the Grid but the problem is that when i am editing this i am getting this error.
"A potentially dangerous Request.Form value was detected from the client (Status="
Here i am using My own template as
UpdateAccount(.Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("UpdateAccount")))
wherein i am not including the Status Field but still getting this error.
My UpdateAccount template is as Follows:
<input type="hidden" name="AccountID" id="AccountID" />
<div class="control-group">
<label class="control-label">Account Type</label>
<div class="controls">
<input type="text" name="AccountType" id="AccountType" />
</div>
</div>
<div class="control-group">
<label class="control-label">Account Name</label>
<div class="controls">
<input type="text" name="AccountName" id="AccountName" />
</div>
</div>
<div class="control-group">
<label class="control-label">Currency</label>
<div class="controls">
<input type="text" name="Currency" id="Currency" />
</div>
</div>
Please help me !!!

You can set a template for just one column like this :
columns.Bound(p => p.AccountType)
.Title("Account Type")
.Width(225)
.Template(#<img src="./Images/accountIco.png" title="#item.AccountName" />#item.AccountType);

Related

Unwanted Autocomplete suggestions ASP.NET MVC-5 Razor

Its shows some unwanted autocomplete suggestions.
I think those suggestions coming from UserName text field.
But I do not find any reason for those suggestions.
Model Code:
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
[Required(ErrorMessage = "Birth Date is Reqired")]
[DataType(DataType.DateTime)]
[Display(Name = "Birth Date")]
public DateTime BirthDate { get; set; }
Razor View:
<div class="container jumbotron" style="background-color:whitesmoke">
<div class="row">
<div class="col-md-4" style="margin-left: 400px; margin-top:30px">
<section id="loginForm">
#Html.ValidationSummary(true)
#using (Html.BeginForm("Registration", "SignUp", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<div class="form-group">
#Html.LabelFor(m => m.FirstName)
#Html.TextBoxFor(m => m.FirstName, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.FirstName)
</div>
<div class="form-group">
#Html.LabelFor(m => m.LastName)
#Html.TextBoxFor(m => m.LastName, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.LastName)
</div>
<div class="form-group">
#Html.LabelFor(m => m.UserName)
#Html.TextBoxFor(m => m.UserName, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.UserName)
</div>
<div class="form-group">
#Html.LabelFor(m => m.EmailAddress)
#Html.TextBoxFor(m => m.EmailAddress, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.EmailAddress)
</div>
<div class="form-group">
#Html.LabelFor(m => m.BirthDate)
<input class="form-control" value="yyyy-MM-dd" name="BirthDate" type="text" id="BirthDate" autocomplete="off">
#Html.ValidationMessageFor(m => m.BirthDate)
</div>
<div class="form-group">
#Html.LabelFor(m => m.PassWord)
#Html.PasswordFor(m => m.PassWord, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.PassWord)
</div>
<div class="form-group">
#Html.LabelFor(m => m.VerifyPassWord)
#Html.PasswordFor(m => m.VerifyPassWord, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.VerifyPassWord)
</div>
<div class="form-group">
#Html.LabelFor(m => m.VersityId)
#Html.TextBoxFor(m => m.VersityId, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.VersityId)
</div>
<div class="form-group">
#Html.LabelFor(m => m.PhoneNumber)
#Html.TextBoxFor(m => m.PhoneNumber, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.PhoneNumber)
</div>
<div class="form-group">
#Html.LabelFor(m => m.Address)
#Html.TextAreaFor(m => m.Address, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.Address)
</div>
<div class="form-group">
<input id="ImageUpload" type="file" name="ImageUpload" />
</div>
<button type="submit" class="btn btn-primary">Save</button>
}
<p>
#Html.ActionLink("Already Have an Account", "LogIn")
</p>
</section>
</div>
</div>
Problem view (Image) :
Problem indicate by red circle
I don't want this kinds of suggestions.
Please help me for get ride of this problem.
Thanks a lot advance
From this site, maybe this is your issue, the autocomplete should do the trick, but if your whole page is rendering over XHTML, then you will need something like this.
https://css-tricks.com/snippets/html/autocomplete-off/
.autocomplete=”off” is not valid markup with XHTML Transitional, which is a common DOCTYPE. Use this to keep a vaild markup
if (document.getElementsByTagName) {
var inputElements = document.getElementsByTagName(“input”);
for (i=0; inputElements[i]; i++) {
if (inputElements[i].className && (inputElements[i].className.indexOf(“disableAutoComplete”) != -1)) {
inputElements[i].setAttribute(“autocomplete”,”off”);
}
}
}

Woocommerce - How to change the html markup of checkout fields on the checkout page?

I use this hook:
add_action( 'woocommerce_after_checkout_billing_form', 'add_custom_field' );
function add_custom_field( $checkout ) {
echo '<div id="custom_field_wrapper">';
woocommerce_form_field( 'custom_field', array(
'type' => 'text',
'class' => array('custom_field_class'),
'label' => __('Custom Field'),
'placeholder' => __('Please input value ...'),
'required' => false, ),
$checkout->get_value( 'custom_field' ) );
echo '</div>';
}
and i get this markup:
<div id="custom_field_wrapper">
<p class="form-row custom_field_class" id="custom_field_field" data-priority="">
<label for="custom_field" class="">Custom Field</label>
<input type="text" class="input-text " name="custom_field" id="custom_field" placeholder="Please input value ..." value="">
</p>
</div>
But the required markup looks like this:
<div class="row order-form__row">
<div class="col-lg-3 col-md-4">
<label class="label" for="index-field">Индекс:</label>
</div>
<div class="col-lg-6 col-md-6">
<input class="input" type="text" name="index" id="index-field"/>
</div>
<div class="col-lg-3 col-md-2"><a class="field-after" href="javascript:void(0);" target="_blank">Забыли индекс?</a></div>
</div>
Kind smart people help solve the dilemma ... How to change the html markup according to the requirements?

Cannot align static fields for Details page in Bootstrap

I want to use label as used "Static Control" label on that page. However, although I use the same Bootstrap version, I cannot aligned my form controls like that (I want the label is right float, data fields is left float -side by side - and there is a ":" sign between them. Howwver, the result is as shown on the image below. Could you please have a look at my code and inform what is wrong?
The code on that page:
<div class="form-group">
<label class="col-md-3 control-label">Static Control</label>
<div class="col-md-9">
<p class="form-control-static"> email#example.com </p>
</div>
</div>
The code I use on my Razor page:
<div class="form-group">
#Html.LabelFor(m => m.Name, new { #class = "col-md-3 control-label" }):
<div class="col-md-9">
#Html.DisplayFor(m => m.Name, new { #class = "form-control-static" })
</div>
</div>
<br />
<div class="form-group">
#Html.LabelFor(m => m.Surname, new { #class = "col-md-3 control-label" }):
<div class="col-md-9">
#Html.DisplayFor(m => m.Surname, new { #class = "form-control-static" })
</div>
</div>
You have two elements which equal 100% width plus the colon, so it pushes the value down a line. You'll need to just code the label instead of using an HtmlHelper to add the colon. Change it to this:
<div class="form-group">
<label class="col-md-3 control-label">#Model.Name:</label>
<div class="col-md-9">
#Html.DisplayFor(m => m.Name, new { #class = "form-control-static" })
</div>
</div>
Here is the final solution fixed the problem. Thanks a lot for all of your helps...
<style>
.col-sm-3 .control-label {
float: right !important;
margin-top: 0 !important;
}
/*Add colon ( : ) to the end of labels */
.col-sm-3 > label:after {
content: " :";
}
</style>
<div class="form-group">
<div class="col-sm-3">
#Html.LabelFor(m => m.Name, new { #class = "control-label" })
</div>
<div class="col-sm-9">
#Html.DisplayFor(m => m.Name)
</div>
</div>
<br />
<div class="form-group">
<div class="col-sm-3">
#Html.LabelFor(m => m.Surname, new { #class = "control-label" })
</div>
<div class="col-sm-9">
#Html.DisplayFor(m => m.Surname)
</div>
</div>
<br />

How to customize Navbar property in Yii2

I have navigation header like this:
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-collapse collapse">
<form class="navbar-form navbar-right" role="search">
<div class="form-group has-feedback">
<input id="searchbox" type="text" placeholder="Search" class="form-control">
<span id="searchicon" class="fa fa-search form-control-feedback"></span>
</div>
</form>
</div><!--/.navbar-collapse -->
</div>
</div>
I have problem when I want to convert this code using yii\bootstrap\NavBar;:
<div class="navbar-collapse collapse">
<form class="navbar-form navbar-right" role="search">
<div class="form-group has-feedback">
<input id="searchbox" type="text" placeholder="Search" class="form-control">
<span id="searchicon" class="fa fa-search form-control-feedback"></span>
</div>
</form>
</div><!--/.navbar-collapse -->
And this is the code of my Layout using yii\bootstrap\NavBar;:
<?php
NavBar::begin([
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar navbar-inverse navbar-fixed-top',
'role' => 'navigation',
],
]);
NavBar::end();
?>
I have been read Navbar Widget, but still don't understand. Is there anyone who can teach me to using Navbar widget on Yii2 framework?.
Ok here is the code for that,here i am just placing the searchbox from exactly what you posted in question and i am guessing that you know how to echo other menu links in navbar
Anyway it goes like this
<?php
NavBar::begin([
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar navbar-inverse navbar-fixed-top',
'role' => 'navigation',
],
]);
$menuItems = [
['label' => 'Home', 'url' => ['controller url here']],
];
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $menuItems,
]);
echo "<form class='navbar-form navbar-right' role='search'>
<div class='form-group has-feedback'>
<input id='searchbox' type='text' placeholder='Search' class='form-control'>
<span id='searchicon' class='fa fa-search form-control-feedback'></span>
</div>
</form>";
NavBar::end();
?>

CSS Display Textboxes

Thanks to James Donnelly, this has been solved. My example has been updated to the working solution.
My reputation isn't high enough so I can't post an image, so I am going to try and describe it as best as possible. I have 7 textboxes and a textarea on a form, and when I load the page, it currently loads each textbox on a separate line.
However, I want the textboxes to load like this:
1 2 3
4 5 6 7
---8--- (span across)
Should I put each row inside a div? I tried floating each textbox to the left, but that does not work correctly. I have Twitter bootstrap setup in my project if that makes things easier.
Here is my working code:
<div class="well">
<h4>Enter Movie in System:</h4>
#using (Html.BeginForm()) {
<div>
<div class="input-prepend">
<span class="add-on"><i class="icon-film"></i></span>
#Html.TextBoxFor(m => m.Title, new { placeholder = "Title" })
#Html.ValidationMessageFor(m => m.Title)
</div>
<div class="input-prepend">
<span class="add-on"><i class="icon-facetime-video"></i></span>
#Html.TextBoxFor(m => m.Director, new { placeholder = "Director" })
#Html.ValidationMessageFor(m => m.Director)
</div>
#* Make dropdown *#
<div class="input-prepend">
<span class="add-on"><i class="icon-tags"></i></span>
#Html.TextBoxFor(m => m.parentGenre, new { placeholder = "Genre" })
#Html.ValidationMessageFor(m => m.parentGenre)
</div>
<div class="input-prepend">
<span class="add-on"><i class="icon-star-empty"></i></span>
#Html.TextBoxFor(m => m.Stars, new { placeholder = "Actor" })
#Html.ValidationMessageFor(m => m.Stars)
</div>
<div class="input-prepend">
<span class="add-on"><i class="icon-time"></i></span>
#Html.TextBoxFor(m => m.Duration, new { placeholder = "Duration (mins)" })
#Html.ValidationMessageFor(m => m.Duration)
</div>
#* Make dropdown *#
<div class="input-prepend">
<span class="add-on"><i class="icon-warning-sign"></i></span>
#Html.TextBoxFor(m => m.Rating, new { placeholder = "Rating" })
#Html.ValidationMessageFor(m => m.Rating)
</div>
<div class="input-prepend">
<span class="add-on"><i class="icon-calendar"></i></span>
#Html.TextBoxFor(m => m.releaseDate, new { placeholder = "Release Date" })
#Html.ValidationMessageFor(m => m.releaseDate)
</div>
<div class="control-group">
<div class="input-prepend">
<span class="add-on"><i class="icon-comment"></i></span>
#Html.TextAreaFor(m => m.Description, new { placeholder = "Description", #class="input-xxlarge" })
#Html.ValidationMessageFor(m => m.Description)
</div>
</div>
<p>
<button class="btn" type="submit" value="Register">Register</button>
</p>
#Html.ValidationSummary()
</div>
}
.content-group is by default set to display:table; which is what's forcing each of your inputs down onto a new line. You'd simply need to put each of your .input-prepend containers into just one container:
<div>
<div class="input-prepend">
<span class="add-on"><i class="icon-tags"></i></span>
#Html.TextBoxFor(m => m.parentGenre, new { placeholder = "Genre" })
#Html.ValidationMessageFor(m => m.parentGenre)
</div>
<div class="input-prepend">
<span class="add-on"><i class="icon-tags"></i></span>
#Html.TextBoxFor(m => m.parentGenre, new { placeholder = "Genre" })
#Html.ValidationMessageFor(m => m.parentGenre)
</div>
<div class="input-prepend">
<span class="add-on"><i class="icon-tags"></i></span>
#Html.TextBoxFor(m => m.parentGenre, new { placeholder = "Genre" })
#Html.ValidationMessageFor(m => m.parentGenre)
</div>
</div>
Is this what u mean?
<div>
<input id="tbx1" />
<input id="tbx2" />
<input id="tbx3" /><br />
<input id="tbx4" />
<input id="tbx5" />
<input id="tbx6" />
<input id="tbx7" />
<span id="span1" style="padding-left:200px">
<input id="tbx8" />
</span>
</div>
you have to post the css style you have tried. but I am guessing that giving the form a float left, width and height should let you be able to float the input fields, make sure none of the first six inputs is greater than 30% of the form width. for the last one width 100%

Resources