I have an enum of some countries:

public enum Countries
{
    USA,
    Canada,
    Mexico,
}

I then have a property on my model:

[Required]
public string Country { get; set; }

In my view I have:

@Html.DropDownList("Country", Html.GetEnumSelectList(typeof(Countries)) ...)

I would like the value of each option in the generated select to be the name of each item from the Countries enum. By default, the value is a zero-based integer.

When i start a new project, click web and select the following options:

Web api project

Then i'm stuck with a new project and not a single thing that I've tried allowed me to interact with my existing MySQL database. Does anyone have a hands on approach that i can use.

What needs to work:

  • Existing database needs to be updated with the user tables automatically.(as it does with the default settings)

What i hope to see in the comments:

  • Start new project
  • Remove X add Y etc
  • Run project, run fiddler, post new user.

P.S I've literary used every resource on the first few Google and Bing pages, read entire blogs and searched everywhere for such a simple thing. Hope you can help.

I have a simple ASP.Net page with a button and a Literal Control on it. On button click i am generating a new dynamic control (imagebutton) and rendering it via HtmlTextWriter to the Literal. On control creation i am also adding an onClick Event which is not getting fired. Here is my code:

aspx

    <asp:Button ID="btnCreate" runat="server" Text="Create" OnClick="btnCreate_Click" />
    <asp:Literal ID="lit" runat="server"></asp:Literal>

cs

public partial class _default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnCreate_Click(object sender, EventArgs e)
    {
        ImageButton dynBtn = new ImageButton();
        dynBtn.ID = "1";
        dynBtn.ImageUrl = "http://cdn.mysitemyway.com/etc-mysitemyway/icons/legacy-previews/icons/matte-blue-and-white-square-icons-symbols-shapes/118240-matte-blue-and-white-square-icon-symbols-shapes-power-button.png";
        dynBtn.Click += new ImageClickEventHandler(dynBtn_click);
        lit.Text = RenderControl(dynBtn);
    }

    private void dynBtn_click(object sender, ImageClickEventArgs e)
    {
        Page.Response.Write("hello!");
    }

    private string RenderControl(Control control)
    {
        StringBuilder sb = new StringBuilder();
        StringWriter sw = new StringWriter(sb);
        HtmlTextWriter writer = new HtmlTextWriter(sw);

        control.RenderControl(writer);
        return sb.ToString();
    }
}

The control is getting created without any errors but the event is not fireing.

'This Code is not working. Please Help. 'Not sure what is needed to do here.

Public Class WebForm2
    Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    ListBox1.Items.Add("test")
    ListBox1.Items.Add("test2")
End Sub

Protected Sub AddOneButton0_Click(sender As Object, e As EventArgs) Handles AddOneButton0.Click
    If (ListBox1.SelectedIndex = -1) Then
        MsgBox("please select an item")
    Else
        ListBox2.Items.Add(ListBox1.SelectedItem)
        ListBox1.Items.Remove(ListBox1.SelectedItem)
    End If
End Sub

End Class

'Adding HTML to help figure out if i did anything wrong with my code.

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="WebForm2.aspx.vb" Inherits="GBATExcel.WebForm2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <!DOCTYPE html>

<html>
<head>
    <title></title>
</head>
<body>
    <div style="height: 904px">

        <asp:ListBox ID="ListBox1" runat="server" style="position:absolute; top: 101px; left: 28px; height: 170px; width: 111px;"></asp:ListBox>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;

        <br />

        <asp:ListBox ID="ListBox2" runat="server" style="position:absolute; top: 103px; left: 223px; height: 167px; width: 131px;"></asp:ListBox>
        <asp:Button ID="RemoveAllButton" runat="server" Text="&lt;&lt;" style="position:absolute; top: 435px; left: 153px;"/>

        <asp:Button ID="AddOneButton2" runat="server" Text="&gt;" style="position:absolute; top: 308px; left: 157px;"/>

        <asp:Button ID="RemoveOneButton2" runat="server" Text="&lt;" style="position:absolute; top: 565px; left: 156px;"/>

        <asp:Button ID="AddAllButton" runat="server" Text="&gt;&gt;" style="position:absolute; top: 194px; left: 153px;"/>

        <asp:ListBox ID="ListBox3" runat="server" style="position:absolute; top: 302px; left: 29px; height: 177px; width: 106px;"></asp:ListBox>

        <asp:ListBox ID="ListBox4" runat="server" style="position:absolute; top: 520px; left: 223px; height: 170px; width: 129px;"></asp:ListBox>

        <asp:Button ID="AddOneButton0" runat="server" Text="&gt;" style="position:absolute; top: 110px; left: 157px;"/>

        <asp:Button ID="RemoveOneButton0" runat="server" Text="&lt;" style="position:absolute; top: 151px; left: 158px;"/>

        <asp:Button ID="RemoveAllButton0" runat="server" Text="&lt;&lt;" style="position:absolute; top: 233px; left: 154px;"/>

        <asp:ListBox ID="ListBox5" runat="server" style="position:absolute; top: 730px; left: 28px; height: 170px; width: 111px;"></asp:ListBox>

        <asp:ListBox ID="ListBox6" runat="server" style="position:absolute; top: 302px; left: 223px; height: 171px; width: 128px;"></asp:ListBox>

        <asp:Button ID="AddOneButton3" runat="server" Text="&gt;" style="position:absolute; top: 737px; left: 156px;"/>

        <asp:Button ID="RemoveOneButton3" runat="server" Text="&lt;" style="position:absolute; top: 350px; left: 157px;"/>

        <asp:Button ID="AddAllButton1" runat="server" Text="&gt;&gt;" style="position:absolute; top: 396px; left: 153px;"/>

        <asp:Button ID="RemoveAllButton1" runat="server" Text="&lt;&lt;" style="position:absolute; top: 648px; left: 152px;"/>

        <asp:ListBox ID="ListBox7" runat="server" style="position:absolute; top: 520px; left: 29px; height: 170px; width: 110px;"></asp:ListBox>

        <asp:ListBox ID="ListBox8" runat="server" style="position:absolute; top: 729px; left: 222px; height: 170px; width: 134px;"></asp:ListBox>

        <asp:Button ID="AddOneButton4" runat="server" Text="&gt;" style="position:absolute; top: 525px; left: 156px;"/>

        <asp:Button ID="RemoveOneButton4" runat="server" Text="&lt;" style="position:absolute; top: 776px; left: 156px;"/>

        <asp:Button ID="AddAllButton2" runat="server" Text="&gt;&gt;" style="position:absolute; top: 607px; left: 152px;"/>

        <asp:Button ID="AddAllButton0" runat="server" Text="&gt;&gt;" style="position:absolute; top: 819px; left: 152px;"/>

        <asp:Button ID="RemoveAllButton2" runat="server" Text="&lt;&lt;" style="position:absolute; top: 864px; left: 152px;"/>

    </div>
    </body>
    </html>
</asp:Content>

'Basically i am having trouble with this and wanted some help

This question already has an answer here:

Line 19:     
static BalloonShopConnectionString1()

Line 20:  
   {

Line 21:
         dbConnectionString = ConfigurationManager.ConnectionStrings["BalloonShopConnection"].ConnectionString;

Line 22:
         dbProviderName = ConfigurationManager.ConnectionStrings["BalloonShopConnection"].ProviderName;

Line 23:         productsPerPage = System.Int32.Parse(ConfigurationManager.AppSettings["ProductsPerPage"]);

Line 21 Error

In our ASP .Net application we are trying to fix XSS vulnerabilities. One of the problems we encountered is that when a query string bellow

ourpage.aspx?__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUKMTAxOTk1NDMxMg9kFgICAw9kFgICEQ8PZBYCHgdvbmNsaWNrBR13aW5kb3cuY2xvc2UoKTsgcmV0dXJuIGZhbHNlO2RkcQEQbb2A2hWZnrS9pcXRF4EDF7Q%3D&__VIEWSTATEGENERATOR=EBC25103&__EVENTVALIDATION=%2FwEdAAi8inwUw%2FyIc%2FUxpyvKpHdeozoJZpuXxkpOVJKRbHyuHmlJEj7l%2FGj1NRvUfGMY22stUEwsJZE1IXwp7R8XUoMjyGtqAqh12zo5yE8Zl7red3Mqtn%2BrBUpq%2FEgsf24SjK%2BWWIA8pj4q9GaeJhWM25CI%2BOt37oCEEXP3EjBFcbJhKGGMTyJjBcvUuHDSprAODp%2BY05Uh&txtName=test81393%22%3balert%281%29%2f%2f827bae775&txtIndustry=test&txtLocation=test&btnSave=Save

to ASP page in development under VS 2010 it gets intercepted and throws error

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> 

which is good. But when we copy the application to IIS 7.5 the request gets through and alert box pops up. What can be wrong?

Thanks in advance.

I'm sure this question will be a duplicate, but I can't get this piece of code to work properly, even after trying to change it in multiple ways following a few examples. When I try to run this code I get an error of

object reference not set to an instance of an object

upon trying to fire the EndInvoke in the callback function. Thing is, the program doesn't even go into MyMethod.

public partial class Ana_UI_CONTROLS_PrintReport : System.Web.UI.UserControl
{
    public delegate DataTable 
      GetDataDelegate(string a, string b, string c, string d, DateTime date);

    public GetDataDelegate myDelegate;

    public void AsyncExport()
    {
        myDelegate = new GetDataDelegate(MyMethod);
        myDelegate.BeginInvoke(
          a, b, c, d, date, new AsyncCallback(LoadDataTableGridCallBack), null);
    }

    private DataTable MyMethod(string a, string b, string c, string d, DateTime date)
    {
        //do something
        return result;
    }

    private void LoadDataTableGridCallBack(IAsyncResult result)
    {
        AsyncResult aResult = (AsyncResult)result;
        GetDataDelegate myDelegate = (GetDataDelegate)aResult.AsyncDelegate;

        DataTable ris = new DataTable();
        try
        {
            ris = myDelegate.EndInvoke(result);
        }
        catch (Exception ex)
        {
            //handle exception.
        }
    }
}

The following exception is occuring in the public string HttpCall(string NvpRequest) method:

'System.Net.ProtocolViolationException' {"You must write ContentLength bytes to the request stream before calling [Begin]GetResponse."}

It occurs on this line of code

//Retrieve the Response returned from the NVP API call to PayPal.

HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();

Here is the code:

using System;
using System.Collections;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Text;
using System.Data;
using System.Configuration;
using System.Web;
using WingtipToys;
using WingtipToys.Models;
using System.Collections.Generic;
using System.Linq;

public class NVPAPICaller
{
  //Flag that determines the PayPal environment (live or sandbox)
  private const bool bSandbox = true;
private const string CVV2 = "CVV2";

// Live strings.
private string pEndPointURL = "https://api-3t.paypal.com/nvp";
private string host = "www.paypal.com";

// Sandbox strings.
private string pEndPointURL_SB = "https://api-3t.sandbox.paypal.com/nvp";
private string host_SB = "www.sandbox.paypal.com";

private const string SIGNATURE = "SIGNATURE";
private const string PWD = "PWD";
private const string ACCT = "ACCT";

//Replace <Your API Username> with your API Username
//Replace <Your API Password> with your API Password
//Replace <Your Signature> with your Signature
//
// 4/28/2016 Updated by Mike to test the Paypal API 
// Commented out these three (3) lines below and add new credentials
//
//public string APIUsername = "<Your API Username>";
//private string APIPassword = "<Your API Password>";
//private string APISignature = "<Your Signature>";

public string APIUsername = "test@test.com";
private string APIPassword = "Testing123!";
private string APISignature = "MySignature";

private string Subject = "";
private string BNCode = "PP-ECWizard";


//HttpWebRequest Timeout specified in milliseconds 
private const int Timeout = 15000;
private static readonly string[] SECURED_NVPS = new string[] { ACCT, CVV2, SIGNATURE, PWD };

public void SetCredentials(string Userid, string Pwd, string Signature)
{
    APIUsername = Userid;
    APIPassword = Pwd;
    APISignature = Signature;
}

public bool ShortcutExpressCheckout(string amt, ref string token, ref string retMsg)
{
    if (bSandbox)
    {
      pEndPointURL = pEndPointURL_SB;
      host = host_SB;
    }

    string returnURL = "https://localhost:44300/Checkout/CheckoutReview.aspx";
    string cancelURL = "https://localhost:44300/Checkout/CheckoutCancel.aspx";

    NVPCodec encoder = new NVPCodec();
    encoder["METHOD"] = "SetExpressCheckout";
    encoder["RETURNURL"] = returnURL;
    encoder["CANCELURL"] = cancelURL;
    encoder["BRANDNAME"] = "MyBrandNameDuringTesting";
    encoder["PAYMENTREQUEST_0_AMT"] = amt;
    encoder["PAYMENTREQUEST_0_ITEMAMT"] = amt;
    encoder["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
    encoder["PAYMENTREQUEST_0_CURRENCYCODE"] = "USD";

    // Get the Shopping Cart Products
    using (WingtipToys.Logic.ShoppingCartActions myCartOrders = new WingtipToys.Logic.ShoppingCartActions())
    {
      List<CartItem> myOrderList = myCartOrders.GetCartItems();

      for (int i = 0; i < myOrderList.Count; i++)
      {
        encoder["L_PAYMENTREQUEST_0_NAME" + i] = myOrderList[i].Product.ProductName.ToString();
        encoder["L_PAYMENTREQUEST_0_AMT" + i] = myOrderList[i].Product.UnitPrice.ToString();
        encoder["L_PAYMENTREQUEST_0_QTY" + i] = myOrderList[i].Quantity.ToString();
      }
    }

    string pStrrequestforNvp = encoder.Encode();
    string pStresponsenvp = HttpCall(pStrrequestforNvp);

    NVPCodec decoder = new NVPCodec();
    decoder.Decode(pStresponsenvp);

    string strAck = decoder["ACK"].ToLower();
    if (strAck != null && (strAck == "success" || strAck == "successwithwarning"))
    {
      token = decoder["TOKEN"];
      string ECURL = "https://" + host + "/cgi-bin/webscr?cmd=_express-checkout" + "&token=" + token;
      retMsg = ECURL;
      return true;
    }
    else
    {
      retMsg = "ErrorCode=" + decoder["L_ERRORCODE0"] + "&" +
      "Desc=" + decoder["L_SHORTMESSAGE0"] + "&" +
      "Desc2=" + decoder["L_LONGMESSAGE0"];
      return false;
    }
  }

public bool GetCheckoutDetails(string token, ref string PayerID, ref NVPCodec decoder, ref string retMsg)
{
    if (bSandbox)
    {
      pEndPointURL = pEndPointURL_SB;
    }

    NVPCodec encoder = new NVPCodec();
    encoder["METHOD"] = "GetExpressCheckoutDetails";
    encoder["TOKEN"] = token;

    string pStrrequestforNvp = encoder.Encode();
    string pStresponsenvp = HttpCall(pStrrequestforNvp);

    decoder = new NVPCodec();
    decoder.Decode(pStresponsenvp);

    string strAck = decoder["ACK"].ToLower();
    if (strAck != null && (strAck == "success" || strAck == "successwithwarning"))
    {
      PayerID = decoder["PAYERID"];
      return true;
    }
    else
    {
      retMsg = "ErrorCode=" + decoder["L_ERRORCODE0"] + "&" +
      "Desc=" + decoder["L_SHORTMESSAGE0"] + "&" +
      "Desc2=" + decoder["L_LONGMESSAGE0"];

      return false;
    }
  }

public bool DoCheckoutPayment(string finalPaymentAmount, string token, string PayerID, ref NVPCodec decoder, ref string retMsg)
{
    if (bSandbox)
    {
      pEndPointURL = pEndPointURL_SB;
    }

    NVPCodec encoder = new NVPCodec();
    encoder["METHOD"] = "DoExpressCheckoutPayment";
    encoder["TOKEN"] = token;
    encoder["PAYERID"] = PayerID;
    encoder["PAYMENTREQUEST_0_AMT"] = finalPaymentAmount;
    encoder["PAYMENTREQUEST_0_CURRENCYCODE"] = "USD";
    encoder["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";

    string pStrrequestforNvp = encoder.Encode();
    string pStresponsenvp = HttpCall(pStrrequestforNvp);

    decoder = new NVPCodec();
    decoder.Decode(pStresponsenvp);

    string strAck = decoder["ACK"].ToLower();
    if (strAck != null && (strAck == "success" || strAck == "successwithwarning"))
    {
      return true;
    }
    else
    {
      retMsg = "ErrorCode=" + decoder["L_ERRORCODE0"] + "&" +
      "Desc=" + decoder["L_SHORTMESSAGE0"] + "&" +
      "Desc2=" + decoder["L_LONGMESSAGE0"];

      return false;
    }
  }

public string HttpCall(string NvpRequest)
{
    string url = pEndPointURL;

    string strPost = NvpRequest + "&" + buildCredentialsNVPString();
    strPost = strPost + "&BUTTONSOURCE=" + HttpUtility.UrlEncode(BNCode);

    HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
    objRequest.Timeout = Timeout;
    objRequest.Method = "POST";
    objRequest.ContentLength = strPost.Length;

    try
    {
      using (StreamWriter myWriter = new StreamWriter(objRequest.GetRequestStream()))
      {
        myWriter.Write(strPost);
      }
    }
    catch (Exception e)
    {
      // Log the exception.
      WingtipToys.Logic.ExceptionUtility.LogException(e, "HttpCall in PayPalFunction.cs");
    }

    //Retrieve the Response returned from the NVP API call to PayPal.
    HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
    string result;
    using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
    {
      result = sr.ReadToEnd();
    }
    return result;
  }

private string buildCredentialsNVPString()
  {
    NVPCodec codec = new NVPCodec();

    if (!IsEmpty(APIUsername))
      codec["USER"] = APIUsername;

    if (!IsEmpty(APIPassword))
      codec[PWD] = APIPassword;

    if (!IsEmpty(APISignature))
      codec[SIGNATURE] = APISignature;

    if (!IsEmpty(Subject))
      codec["SUBJECT"] = Subject;

    codec["VERSION"] = "88.0";

    return codec.Encode();
  }

public static bool IsEmpty(string s)
  {
    return s == null || s.Trim() == string.Empty;
  }
}

public sealed class NVPCodec : NameValueCollection
{
  private const string AMPERSAND = "&";
  private const string EQUALS = "=";
  private static readonly char[] AMPERSAND_CHAR_ARRAY = AMPERSAND.ToCharArray();
  private static readonly char[] EQUALS_CHAR_ARRAY = EQUALS.ToCharArray();

  public string Encode()
  {
    StringBuilder sb = new StringBuilder();
    bool firstPair = true;
    foreach (string kv in AllKeys)
    {
      string name = HttpUtility.UrlEncode(kv);
      string value = HttpUtility.UrlEncode(this[kv]);
      if (!firstPair)
      {
        sb.Append(AMPERSAND);
      }
      sb.Append(name).Append(EQUALS).Append(value);
      firstPair = false;
    }
    return sb.ToString();
  }

  public void Decode(string nvpstring)
  {
    Clear();
    foreach (string nvp in nvpstring.Split(AMPERSAND_CHAR_ARRAY))
    {
      string[] tokens = nvp.Split(EQUALS_CHAR_ARRAY);
      if (tokens.Length >= 2)
      {
        string name = HttpUtility.UrlDecode(tokens[0]);
        string value = HttpUtility.UrlDecode(tokens[1]);
        Add(name, value);
      }
    }
  }

  public void Add(string name, string value, int index)
  {
    this.Add(GetArrayName(index, name), value);
  }

  public void Remove(string arrayName, int index)
  {
    this.Remove(GetArrayName(index, arrayName));
  }

  public string this[string name, int index]
  {
    get
    {
      return this[GetArrayName(index, name)];
    }
    set
    {
      this[GetArrayName(index, name)] = value;
    }
  }

  private static string GetArrayName(int index, string name)
  {
    if (index < 0)
    {
      throw new ArgumentOutOfRangeException("index", "index cannot be negative : " + index);
    }
    return name + index;
  }

I am trying to create an object with Data Annotations and use other objects inside it which use Data Annotations themselves. Ex:

public class ParticipationModel
{

    [Required]
    public Object1 obj { get; set; }

    public List<Object2> Listofobj2 { get; set; }

}

public class Object2
{
    [Required]
    public String TypeOfThing { get; set; }
}

My Question is if the Data Annotation will only require the TypeOfThing if the Listofobj2 is in fact instantiated.

While testing had a couple of weird reactions from this Type of Data Structure.

How to make fancybox works on ajax generated element? I know this has been asked a lot of times in Stackoverflow, and a lot of questions are only applicable on the previous version of fancybox usually 1.3.4 and I'm currently using 2.1.5 which they have different structure of codes.

For 1.3.4 the code structure is:

$.fn.fancybox = function(options) {
        $(this)
            .die('click.fb')
            .live('click.fb', function(e) {
                $(this).data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {})));
                e.preventDefault();

                if (busy) {
                    return;
                }

                busy = true;

                $(this).blur();

                selectedArray   = [];
                selectedIndex   = 0;

                var rel = $(this).attr('rel') || '';

                if (!rel || rel == '' || rel === 'nofollow') {
                    selectedArray.push(this);

                } else {
                    selectedArray   = $("a[rel=" + rel + "], area[rel=" + rel + "]");
                    selectedIndex   = selectedArray.index( this );
                }

                fancybox_start();

                return false;
            });

        return this;
    };

User suggested fix is:

$.fn.fancybox = function(options) {
    if (!$(this).length) {
        return this;
    }

    $(this)
        .unbind('click.fb')
        .live('click.fb', function(e) {
         $(this).data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {})))
            e.preventDefault();

              //...
          }
//...

However in version 2.1.5 the structure is:

$.fn.fancybox = function (options) {
        var index,
            that     = $(this),
            selector = this.selector || '',
            run      = function(e) {
                var what = $(this).blur(), idx = index, relType, relVal;

                if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && !what.is('.fancybox-wrap')) {
                    relType = options.groupAttr || 'data-fancybox-group';
                    relVal  = what.attr(relType);

                    if (!relVal) {
                        relType = 'rel';
                        relVal  = what.get(0)[ relType ];
                    }

                    if (relVal && relVal !== '' && relVal !== 'nofollow') {
                        what = selector.length ? $(selector) : that;
                        what = what.filter('[' + relType + '="' + relVal + '"]');
                        idx  = what.index(this);
                    }

                    options.index = idx;

                    // Stop an event from bubbling if everything is fine
                    if (F.open(what, options) !== false) {
                        e.preventDefault();
                    }
                }
            };

        options = options || {};
        index   = options.index || 0;

        if (!selector || options.live === false) {
            that.unbind('click.fb-start').bind('click.fb-start', run);

        } else {
            D.undelegate(selector, 'click.fb-start').delegate(selector + ":not('.fancybox-item, .fancybox-nav')", 'click.fb-start', run);
        }

        this.filter('[data-fancybox-start=1]').trigger('click');

        return this;
    };

and I'm calling fancybox with something like:

@Html.ActionLink(Strings.Link_ViewFullList, "UserFullList", new { id = 1 }, new { @class = "fancybox fancybox.ajax", id = "viewUsersList" })

And this link is generated only in an ajax call.

I tried changing this line of code in version 2.1.5:

if (!selector || options.live === false) {
                that.unbind('click.fb-start').bind('click.fb-start', run);

            } else {
                D.undelegate(selector, 'click.fb-start').delegate(selector + ":not('.fancybox-item, .fancybox-nav')", 'click.fb-start', run);
            }

If I could make it work. Now how do I make this work? Or Am I in a wrong line of codes?

New to Umbraco and having a problem updating the code of an existing site.

Updating views works ok but when updating a model and/or controller the site does not change.

Do I need to compile or clear something?

I am creating dynamic tables with bootstrap. I am getting data by ajax request and after I am making X bootstrap tables. It works as below

success: function (succ) {
    $("#showMonth").text(monthArray[currentVisibleMonth - 1] + " " + currentVisibleYear);
    $("#tables").empty();
    var efficiencyDurations = succ.efficiencyDuration;
    var reportTables = succ.reportArray;
    var reportDurations = succ.totalDurations;
    $(succ.reportArray).each(function (i) {
        $(reportTables[i].data).each(function (datearray) {
            var date = new Date(parseInt(reportTables[i].data[datearray].Date.substr(6)));
            var formattedDate = $.format.date(date, "dd-MM-yyyy");
            reportTables[i].data[datearray].Date = formattedDate;
        });

        var duration = efficiencyDurations[i];
        $("#tables").append('<span class="text-primary"><b>' + reportTables[i].data[0].ClientName + " / " + reportTables[i].data[0].ProjectName + " / " + reportTables[i].data[0].TaskName + '</b></span> <span class="text-danger"><b>(' + duration + ")</b></span>");
        $("#tables").append("<table id=table" + i + '><thead><tr class="clickable-row"> <th data-field="Date" class="col-md-1"> Date </th><th data-field="Description" class="col-md-8"> Description</th> <th data-field="Duration" class="col-md-1">Real Duration</th> <th class="col-md-1" data-field="EfficiencyDuration">Duration</th> </tr></thead></table>');

        $("#table" + i).bootstrapTable({
            data: reportTables[i].data,
            striped: true
        });
    });

Now the point is that I want to make one column visible just for administrator. But as I noticed I cannot append razorhtml with jQuery.append().

Does anyone have idea how to hide/show column depend of

UserInRole("")?

In my web application I have an admin page where I am able to customize my connection strings at runtime, let's say the connection strings look like the following:

<add name="newString1" connectionString="Data Source=;Initial Catalog=;User ID=; Password="
<add name="newString2" connectionString="Data Source=;Initial Catalog=;User ID=; Password="
<add name="newString3" connectionString="Data Source=;Initial Catalog=;User ID=; Password="
<add name="newString4" connectionString="Data Source=;Initial Catalog=;User ID=; Password="
<add name="newString5" connectionString="Data Source=;Initial Catalog=;User ID=; Password="

The connection strings are blank at first until the user changes them from the admin page, once changed they are written to the web.config file and will always be there even if the application is restarted.

I then have an SQL datasource like the following:

 <asp:SqlDataSource 
            ID="SqlDataSource1" 
            runat="server" 
            ConnectionString="<%$ ConnectionStrings:newString1 %>"
            SelectCommand="SELECT * FROM [Table] WHERE ([Code] = @Code )">
            <SelectParameters>
                <asp:ControlParameter ControlID="dropdownlist" Name="Code" PropertyName="Text" Type="String" />
            </SelectParameters>  
</asp:SqlDataSource>

Because I am able to overwrite any of the connection strings, let's say I have 3 sets of data and each set of data is on a different server, and for example let's say the SQL datasource handled logins. (the one provided doesn't, that is just an example)

how would I go about checking which connection string me or someone else has saved the logins connection string to? has the user saved the connection string to the logins database in newstring1? newstring2? .. and so on.

From testing I've realised I am unable to use multiple connection strings in one data source.

This question already has an answer here:

i have a mp3 website so i want that visitor on my site can share MP3 on FaceBook, the way it play on their wall. Can anyone suggest me some way please?

<meta name="medium" content="video"> <meta name="title" content="Flowplayer Demo Video"> <meta name="description" content= "This Flowplayer demo video is coming from a page providing only the most minimal content to share a video on Facebook with Flowplayer."> <meta name="video_type" content="application/x-shockwave-flash"> <meta name="video_height" content="300"> <meta name="video_width" content="500"> <link rel="video_src" href= "http://flowplayer.blacktrash.org/flowplayer-3.2.18.swf?config=%7B%27clip%27%3A%7B%27url%27%3A%27http%3A%2F%2Fstream.flowplayer.org%2Fflowplayer-700.flv%27%7D%7D"> <link rel="image_src" href="http://flowplayer.org/img/home/flow_eye.jpg"> <meta property="og:url" content="http://flowplayer.blacktrash.org/fbshare.html" /> <meta property="og:site_name" content="Flowplayer Demos" /> <meta property="og:type" content="movie" /> <meta property="og:title" content="Flowplayer Demo Video"/> <meta property="og:description" content= "This Flowplayer demo video is coming from a page providing only the most minimal content to share a video on Facebook with Flowplayer."> <meta property="og:video:height" content="300"> <meta property="og:video:width" content="500"> <meta property="og:image" content="http://flowplayer.org/img/home/flow_eye.jpg"> <meta property="og:image:secure_url" content= "https://d12zt1n3pd4xhr.cloudfront.net/fp/img/flow_eye.jpg"> <meta property="og:video:type" content="application/x-shockwave-flash"> <meta property="og:video" content= "http://flowplayer.blacktrash.org/flowplayer-3.2.18.swfconfig=%7B%27clip%27%3A%7B%27url%27%3A%27http%3A%2F%2Fstream.flowplayer.org%2Fflowplayer-700.flv%27%7D%7D"> <meta property="og:video:secure_url" content= "https://d12zt1n3pd4xhr.cloudfront.net/fp/swf/flowplayer-3.2.18.swf?config=%7B%27clip%27%3A%7B%27url%27%3A%27https%3A%2F%2Fd12zt1n3pd4xhr.cloudfront.net%2Ffp%2Fflowplayer-700.flv%27%7D%7D">

When I use get_selected to get the ids of the selected nodes it returns an array with the items in the order that they were selected.

How can I return this array in the order that the nodes appear on the tree itself(From top to bottom on the screen)?

My View List is like this in asp.net mvc5 crud application and already tried like this as shown in fig. I want to when I click Download action link the corresponding file (image) should download. I will appreciate for your help in this regard. MVC5_image_download

How to asynchronously download multiple amazon glacier files in asp.net web application. I am using .Net 3.5.

My C# web application uses Entity Framework 7 code-first. The DbContext is scoped to the lifetime of the HTTP request. There is a UnitOfWork class that wraps this DbContext. This gets injected into most of the services that need to perform Crud operations on the database.

The application also has an AuditService which is used to audit errors when exceptions are thrown. I don't want to inject the DbContext that is scoped to the HTTP request into this service because if an exception is thrown I only want to save the audit entry to the database and disregard any other pending changes. So it makes sense to inject a new instance of the UnitOfWork/DbContext in this case.

Is it possible to configure an IoC container so that when a UnitOfWork is injected into the AuditService, it should instantiate a new instance of the UnitOfWork (wrapping up a new instance of the DbContext)? But for all other services the UnitOfWork/DbContext that is scoped to the HTTP request should be injected instead?

I'm using Microsoft's built-in IoC container that comes with ASP.NET Core however examples using other IoC containers (e.g. StructureMap) would also be helpful.

I have this piece of code(WebMethod) through which i am sending notification(Messaging) from web to android device using GCM but now i want to send back from android to web is there any way ???

[WebMethod]
    public static string AndroidPush( string sender_gcm_id, string to, string message)
    {
        string from = HttpContext.Current.Session["user"].ToString();
        string regId = to;
        var applicationID = "<MY APP ID>";
        var SENDER_ID = "<DEFAULT SENDER ID>";
        System.Net.WebRequest tRequest = System.Net.WebRequest.Create("https://android.googleapis.com/gcm/send");
        tRequest.Method = "post";
        tRequest.ContentType = " application/x-www-form-urlencoded;charset=UTF-8";
        tRequest.Headers.Add(string.Format("Authorization: key={0}", applicationID));
        tRequest.Headers.Add(string.Format("Sender: id={0}", SENDER_ID));

        //Data post to server                                                                                                                                         
        string postData = "delay_while_idle=0&data.sender=" + from + "&data.sender_gcm_id=" + sender_gcm_id + "&data.message=" + message + "&data.time=" + System.DateTime.Now.ToString() + "&registration_id=" + regId + "";
        Byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(postData);
        tRequest.ContentLength = byteArray.Length;
        System.IO.Stream dataStream = tRequest.GetRequestStream();
        dataStream.Write(byteArray, 0, byteArray.Length);
        dataStream.Close();
        System.Net.WebResponse tResponse = tRequest.GetResponse();
        dataStream = tResponse.GetResponseStream();
        System.IO.StreamReader tReader = new System.IO.StreamReader(dataStream);
        String sResponseFromServer = tReader.ReadToEnd();   //Get response from GCM server.
        string response = sResponseFromServer;
        tReader.Close();
        dataStream.Close();
        tResponse.Close();
        return response;
    }

Thanks In Advance

I want to encrypt query string for all of my project it' work for me but not for post back URL when i use post back URL it did not work for me. and i want it works automatically it's not a small project to change the code please help me if anyone know thanks.

this is my web config code:

  <modules>
    <add type="QueryStringModule" name="QueryStringModule"/>
</modules>

and add this file in App code folder File Link

Note: Not Work for Post back URL.

I am working on a website built using the ASP.Net Boilerplate. I have a service containing a method, which adds a candidate to the database and then triggers an event. During the event I need to update the candidate, but I am finding this is not possible because at that point it still hasn't been added to the database. My code looks like this:

[AbpAuthorize(RecruitmentPermissions.Recruitment_Candidates_Create)]
    protected virtual async Task CreateCandidateAsync(CandidateEditDto input, bool suppressEvents = false)
    {
        var candidate = input.MapTo<Candidate>();
        candidate.Id = Guid.NewGuid();

        if (candidate.User.TenantId == null)
        {
            Abp.Authorization.Users.UserRole userRole = new Abp.Authorization.Users.UserRole()
            {
                RoleId = 3
            };

            candidate.User.TenantId = AbpSession.TenantId;

            candidate.User.Name = input.FirstName;
            candidate.User.Surname = input.Surname;
            candidate.User.UserName = input.Username ?? input.EmailAddress;
            candidate.User.Password = new PasswordHasher().HashPassword(input.Password);
            candidate.User.IsActive = true;
            candidate.User.EmailAddress = input.EmailAddress;
            candidate.User.Roles = new List<Abp.Authorization.Users.UserRole>()
            {
                userRole
            };
            candidate.User.CreatorUserId = AbpSession.UserId;
        }

        // wait for insertion before firing event
        _unitOfWorkManager.Current.Completed += (sender, args) =>
        {
            if (!suppressEvents)
                EventBus.Trigger(new InsertCandidateEventData { candidate = candidate });
        };

        await _candidateRepository.InsertAsync(candidate);

    }

According to the documentation, using _unitOfWorkManager.Current.Completed should fire the code inside the { } after the unit of work has completed, but that isn't happening here.

Can anyone suggest how I can get the candidate into the database before triggering the event?