|
Can anybody tell me the Use of Delegate with real life example (program)?
You can e-mail me on theprofessional1992@gmail.com
|
|
|
|
|
|
By publishing your email address here, you invite spammers to contact you. That's not professional, is it?
|
|
|
|
|
I am new to MVC4. I am trying to issue ajax call on the button click to receive partial view with the loaded dropdown list. It looks like Ajax call never reaches controller's method GetMyList(). What is wrong with my code ? Thank you
//in mypage.cshtml
@model IEnumerable<MyProject.Models.MyModel>
@{
ViewBag.Title = "MyPage";
Layout = "~/Views/Shared/_MyLayout.cshtml";
}
<div>
....
<div>
<button id="btnGetList">Find</button>
</div>
<div id="divWithPartialView">
@Html.Partial("_MyPartialView", Model) // displayed on initial page load
</div>
...
</div>
@section MySection{
<script type="text/javascript">
$('#btnGetList').on('click', function (event) {
alert("go get list"); // shows up
var myName = "Jo";
$.ajax({
type: "POST",
url: "Main/GetMyList",
data: myName,
success: function (data) {
alert("list is here"); //does Not show up
$("#divWithPartialView").html(data);
}
});
alert("after ajax"); //shows up
})
</script>
}
// Controller
namespace MyProject.Controllers
{
public class MainController: Controller
{
............
[HttpGet]
public ActionResult MyPage()
{
List<MyModel> myList = new List<MyModel>();
return View(myList);
}
public ActionResult GetMyList(string myName)
{
MyModel mm = new MyModel();
List<MyModel> myList = mm.GetNames(myName); // using search criteria entered on the previous Application page
return PartialView("_MyPartialView", myList);
}
}
}
//Partial View: _MyPartialView.cshtml
@model IEnumerable<MyProject.Models.MyModel>
<label>Select your name:</label>
<select id="lstNames">
<option value="0">- select name -</option>
@foreach (var name in Model)
{
<option value="@name.id">@name.myName</option>
}
</select>
//Model
public class MyModel
{
public int id { get; private set; }
public string myName { get; set; }
public List<MyModel> GetNames(string myName)
{
List<MyModel> myList = new List<MyModel>();
//code to find names that start with "Jo"
return myList;
}
}
|
|
|
|
|
|
Try...
$.ajax({
...
...
url: '@Url.Action("ActionName","ControllerName")',
...
...
})
Pratik Bhuva
---------------
The night is darkest just before the dawn. And I promise you, the dawn is coming
|
|
|
|
|
Hi,
I am getting problem in rebind radgrid on radwindow close because i have to rebind 3 grid on parent page. It is rebinding just last grid which i have mentioned in code.
Following code i have used in my code
///------ In radwindow javascript code -------
function clientClose(arg) {
getRadWindow().close(arg);
var oWin = getRadWindow();
var parentWindow = oWin.BrowserWindow;
// top.location.href = top.location.href;
parentWindow.refreshGrid();
}
/// ---------In parent page javascirpt code -----
function refreshGrid() {
var masterTable1 = $find("<%=rgDefinition.ClientID%>").get_masterTableView();
var masterTable2 = $find("<%=rgDevelopment.ClientID%>").get_masterTableView();
var masterTable3 = $find("<%=rgTesting.ClientID%>").get_masterTableView();
masterTable1.rebind();
masterTable2.rebind();
masterTable3.rebind();
}
Problem is that ---- this code rebinding my last grid means masterTable3.rebind(); because it is in the last of code.
|
|
|
|
|
|
Hi,
I tried to return a variable value from SP. Pl help on this.
|
|
|
|
|
Help with what? Please edit your question and put some proper detail in it.
Veni, vidi, abiit domum
|
|
|
|
|
|
Have you ever used iron speed designer? What do you think of it? Any good or bad experience?
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Shopping
{
public class Cart
{
private int _IDproduct;
private string _nameProduct;
private int _Quantity;
private string _ImageUrl;
private double _Price;
private double _Total;
public Cart(){}
public Cart(int IDProduct, string NameProduct, int Quantity, string ImageURL, double Price){
_IDproduct = IDProduct;
_nameProduct = NameProduct;
_Quantity = Quantity;
_ImageUrl = ImageURL; ;
_Price = Price;
_Total = Price*Quantity;
}
public int IDProduct {
get { return _IDproduct; }
set { _IDproduct = value; }
}
public string NameProduct
{
get { return _nameProduct; }
set { _nameProduct = value; }
}
public int Quantity
{
get { return _Quantity; }
set { _Quantity = value; }
}
public string ImageURL
{
get { return _ImageUrl; }
set { _ImageUrl = value; }
}
public double Price
{
get { return _Price; }
set { _Price = value; }
}
public double Total
{
get { return _Price*_Quantity; }
}
}
public class CartItem{
private DateTime _dateCreate;
private DateTime _dateUpdate;
private List<Cart> _Item;
public CartItem() {
if(this._Item==null){
this._Item = new List<Cart>();
this._dateCreate = DateTime.Now;
}
}
public List<Cart> Item {
get { return _Item; }
set { _Item = value; }
}
public void Insert(int IDProduct, int Quantity, string ImageURL, string NameProuct, double Price) {
}
}
}
|
|
|
|
|
I'm not sure what your question exactly is.
if(this._Item==null)
This statement checks to see if the list has anything in it. If it doesn't then it will create a new list so you can store Cart objects in it
|
|
|
|
|
It is the constructor code for a CartItem object, although the if clause would seem redundant, as those two items would (presumably) always need to be set in the constructor. I'm not quite sure why a CartItem would hold a List of Cart objects, but no doubt there is a good reason.
Veni, vidi, abiit domum
|
|
|
|
|
I'm working on trying to make my website for multiple languages.
Based on my reading I am looking at creating a LocalizedText.resx file as the fall-back language (English) when it doesn't detect.
Anyways I have to work on replacing all the text to read from this file (or the other languages files).
The documentation says use <%$ Resources:LocalizedText, <mykey> %> but the problem is you can't just put them on a page. You have to use the Text= within a control or Literal.
Can I not just do <%= Resources.LocalizedText.mykey %> instead? I would hate to replace ALL text with a control... wouldn't that just increase the viewstate on the page?
|
|
|
|
|
Why not try it and see if it works?
With regards ViewState, you can set
EnableViewState="false"
either for an individual control, or at the page level if you can get away with that.
|
|
|
|
|
how to display pop up window with text box, using java script,when click a asp.net button
|
|
|
|
|
|
what r u using modalpop up or div?
if u r using modal pop up then
write like $find(popname).showPopup();
popname= behaviourID
|
|
|
|
|
function OpenFloatingForm(target, id, SecondId) {
var pnlId = "";
var page = "";
var maskId = "";
var z_index = "";
var margin = 30;
switch (target) {
case "Donor":
pnlId = "#pnlFloating1";
page = "DonationForm.aspx";
maskId = "#mask1";
z_index = "100";
break;
case "Payment":
pnlId = "#pnlFloating1";
page = "PaymentRealizationDetailForm.aspx";
maskId = "#mask1";
z_index = "100";
break;
}
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set height and width to mask to fill up the whole screen
$(maskId).css({ 'width': maskWidth + 'px', 'height': maskHeight + 'px', 'z-index': z_index });
$(maskId).show();
var scrollTop = $(document).scrollTop();
var docWidth = document.body.clientWidth;
var docHeight = $(window).height();
$(pnlId).width(docWidth - 2 * margin);
$(pnlId).height(docHeight - (margin * 2));
$(pnlId).css('left', margin);
$(pnlId).css('top', margin + scrollTop);
var frame = $(pnlId).find('iframe');
frame.attr('src', "blank.htm");
frame.width($(pnlId).width());
frame.height($(pnlId).height() - 25);
var param2 = (SecondId > 0) ? "&PaymentID=" + SecondId : "";
frame.attr('src', page + "?DonorID=" + id + param2);
$(pnlId).fadeIn('slow', function () {
});
return false;
}
|
|
|
|
|
Hello everybody,i've a problem like this. :((
i have a form sign up with more 100 field input,
i don't wana save all them with tradition method,
i wana save all them like CTRL + S in browsers, by the way,i'll have all data that users push in my fields.
How can i get it? Please help me.
My language i used is asp.net
modified 29-Oct-13 5:36am.
|
|
|
|
|
First you have to disable Ctrl + S Shortcut so that the browser does not try to save the html page,
Add a button and set the style property to "display:none", then you can trigger the button using jquery.
Here is an example of how to disable the shortcut and trigger the button: (did not try this myself, but you get the idea)
$(window).keydown( function (event) {
if (event.which == 83 && event.ctrlKey) {
$('#<%=btnMyButton.ClientID %>').click();
event.preventDefault();
return false;
}
});
|
|
|
|
|
Many thanks to Blikkies, i'll try it.
Anyone else?
I wana get more experience
Thanks to viewing
|
|
|
|
|
Hi Blikkies,
I was try it but not success.Maybe is my
lore. how i can i make it?
|
|
|
|