Hi
Here you can get selected element of Multi selection list using Select2 Jqyery.
Jquery Code
var AuthorList= $("select#AuthorList").select2("val");
-----------------------------------------------------------------------
2. How to set MultiSelection List?
First Get Selected value from your database and add into Hidden Field
like.
Then
Var authlist="";
var a_options = [];
$.each($("#AuthorListoption"), function () {
if (authlist.toLowerCase().indexOf($(this).attr("value")) >= 0) {
a_options.push($(this).attr("value"));
}
});
$("select#AuthorList").select2("val", a_authlist);
HAPPY CODING
Showing posts with label Jquery. Show all posts
Showing posts with label Jquery. Show all posts
Wednesday, April 10, 2013
How To Bind MultiSelection List with Select2 Jquery in MVC
Action
------------------
Public ActionResult Author()
{
SelectList AuthorList= null;
IEnumerable Author = AuthorList.AsEnumerable().Select(c => new SelectListItem()
{
Text = objauth.ReplaceTagValueToTerm(c.TagValue, c.Term),
Value = c.Id.ToString(),
Selected = true,
});
Newterms = new SelectList(Author, "Value", "Text");
ViewBag.AuthorList= Newterms;
}
}
-------------------------------------------------------------------------------------
View Page
@Html.DropDownList("infoTypes", (SelectList)ViewData["AuthorList"], new { @class = "NewCssdropdown", multiple = "" })
---------------------------------------------------------------------
Jquery
$("#AuthorList").select2(
{
maximumSelectionSize: 4 // Here You can define maximum selection
});
HAPPY CODING
------------------
Public ActionResult Author()
{
SelectList AuthorList= null;
IEnumerable Author = AuthorList.AsEnumerable().Select(c => new SelectListItem()
{
Text = objauth.ReplaceTagValueToTerm(c.TagValue, c.Term),
Value = c.Id.ToString(),
Selected = true,
});
Newterms = new SelectList(Author, "Value", "Text");
ViewBag.AuthorList= Newterms;
}
}
-------------------------------------------------------------------------------------
View Page
@Html.DropDownList("infoTypes", (SelectList)ViewData["AuthorList"], new { @class = "NewCssdropdown", multiple = "" })
---------------------------------------------------------------------
Jquery
$("#AuthorList").select2(
{
maximumSelectionSize: 4 // Here You can define maximum selection
});
HAPPY CODING
How to Bind Select2 Jquery in MVC
Action
------------------
Public ActionResult Author()
{
SelectList Newterms = null;
IEnumerable Author = AuthorList.AsEnumerable().Select(c => new SelectListItem()
{
Text = objauth.ReplaceTagValueToTerm(c.TagValue, c.Term),
Value = c.Id.ToString(),
Selected = true,
});
Newterms = new SelectList(Author, "Value", "Text");
ViewBag.NewTerms = Newterms;
}
}
-------------------------------------------------------------------------------------
View Page
@Html.DropDownList("NewTerms", (SelectList)ViewData["NewTerms"], new { @class = "NewCssdropdown" })
--------------------------------------------------------------------------------------
Jquery
---------------------------------------------------------------------------------------------
HAPPY CODING
------------------
Public ActionResult Author()
{
SelectList Newterms = null;
IEnumerable
{
Text = objauth.ReplaceTagValueToTerm(c.TagValue, c.Term),
Value = c.Id.ToString(),
Selected = true,
});
Newterms = new SelectList(Author, "Value", "Text");
ViewBag.NewTerms = Newterms;
}
}
-------------------------------------------------------------------------------------
View Page
@Html.DropDownList("NewTerms", (SelectList)ViewData["NewTerms"], new { @class = "NewCssdropdown" })
--------------------------------------------------------------------------------------
Jquery
---------------------------------------------------------------------------------------------
HAPPY CODING
How to get selected Value from Select2 Jquery.
Hi To know how to bind Dropdown using Select2. Please reffer my old Post
How To Bind Select2
Now i will give you one example to Get Selected Value.
Jquery
--------
var AuthorList= $("#AuthorList").val();
HAPPY CODING
How To Bind Select2
Now i will give you one example to Get Selected Value.
Jquery
--------
var AuthorList= $("#AuthorList").val();
HAPPY CODING
Tuesday, July 17, 2012
Hide/Show Div With Smooth Effect.
Hi i am giving you one example to show and hide div with smooth effect .
My html Code:
<div id="done" style="display:none;">
write content here
</div>
My Java Script Code
<script>
$('#done').fadeIn('slow');
setTimeout(function () {
$('#done').fadeOut('slow');
}, 2000);
</script>
My text To Show
Happy Coding
My html Code:
<div id="done" style="display:none;">
write content here
</div>
My Java Script Code
<script>
$('#done').fadeIn('slow');
setTimeout(function () {
$('#done').fadeOut('slow');
}, 2000);
</script>
My text To Show
Happy Coding
Sunday, July 31, 2011
Wednesday, July 6, 2011
Get Session value With Jquery In Asp.net
$(document).ready(function () {
$("#ContentPlaceHolder1_Btnpos
var val = '<%=Session["UserID"]%>';
if (val != '') {
return true;
}
else {
alert('Please Login First Before Post Comment.');
return false;
}
});
});
Subscribe to:
Posts (Atom)