With VS2013(C#, ASP.NET Web-Form application)

if I type the Following:

M=5

I immediately see the errors displayed on the Errors windows:

; expected
name M does not exist

With VS2015 unless I Build the application nothing is shown, which is quite annoying for a large application.

I tried to see if there is a setting under tools/options but could not find any.

Are you aware of such settings or this behavior is per design?

I have a visual studio solution with 3 projects: DAL, BL & WebApplication1. As you probably assume, the latter is the interface.

I have a connectionString setting defined in the DAL project.

I have published my solution to my web hosting. Everything works fine, but it seems like my website doesn't connect to the database.

I can run WebService commands and get results using the BL, and every result I get that uses the DAL projects is like the DAL cannot connect to the database.

I have already updated the connectionString value to the value given to my by "myLittlePanel".

How can I achieve a connection to the database, or at least have a deeper understanding of the problem I'm facing?

(C#.net, visual studio 2012, Plesk panel & myLittleAdmin for SQL Server)

I am new to MVC and I am working on MVC User Identity. I have created and assigned role for particular user. Now, I want to display the current user information including password, email, username, date of birth etc after the user login to the website.

How can I achieve this one? Once I display current user details, I would like to go for edit part. I am bit confused with Identity. Help would be appreciated.

I've got forms authentication setup as follows:

Web.config:

<authentication mode="Forms">
  <forms slidingExpiration="true" cookieless="UseCookies" timeout="180" loginUrl="Login.aspx" defaultUrl="Default.aspx" name=".ASPXVEWPAUTH"/>
</authentication>
<authorization>
  <deny users="?" />
</authorization>

Login.aspx:

/**Auth logic in button click**/
FormsAuthentication.RedirectFromLoginPage(username, false);

The Login.aspx and Default.aspx pages both live in the root of the application.

Every time I login it redirects me back to the login page. If I just go straight to Default.aspx, it redirects me to the login page as it should, puts Default.aspx into the returnUrl query string as it should, then when I login it redirects me back to Login.aspx with no query string. If I try to login again, with no query string, it still just goes back to Login.aspx.

If I change defaultUrl to a page outside of the root, it redirects fine, no problem.

If I change FormsAuthentication.RedirectFromLoginPage(username, false); to just Response.Redirect("Default.aspx");, the redirect still doesn't work.

If I change <deny users="?" /> to <allow users="?" />, I can load Default.aspx just fine by going directly to it, but the redirect still doesn't work.

I'm at a complete loss here. I've never seen this behaviour before and I'm out of ideas to try. Why won't it let me redirect to a page inside the root of the application? Any help is greatly appreciated.

integration payment gateway in asp.net webform based website. sample code documentation examples are in php only.

I am not sure how to go forward as documentation doesnt seem to be of much help

https://telr.com/support/knowledge-base/hosted-payment-page-integration-guide/

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PaymentProcess.aspx.cs" Inherits="PaymentProcess" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <style>
  #telr {
    width: 100%;
    min-width: 600px;
    height: 600px;
    frameborder: 0;
  }
</style>
</head>
<body>
    <form id="form1" runat="server">
       <p> Enter You Credit Card Details Here</p>
<p><iframe id= " telr " src= " [url obtained from create order] " ></iframe></p>
<div>

 </div>

    </form>

<script type="text/javascript">

    </script>
</body>
</html>

Any help or pointer is appreciated

UPDATE:

I am trying to using HTTPClient for same but i am not sure if i am doing it wring

protected void btn_Click(object sender, EventArgs e)
{

    using (var client = new HttpClient())
    {
        TelrObj obj = new TelrObj();

        obj.ivp_method = "create";
        obj.ivp_store = 12345;
        obj.ivp_cart = "cardid1234";
        obj.ivp_test = 1;
        obj.return_auth = "xxxx-xxxx-xxx";
        obj.return_can = "";
        obj.return_decl = "";
        obj.ivp_amount = 10;
        obj.bill_fname = "David";
        obj.ivp_currency = "USD";

        var str = "{ 'method':'create', 'order':{  'ref':'OrderRef', 'cartid':'cardid1234', 'test':1,'amount':10,'currency':'USD', 'url':'https://secure.telr.com/gateway/process.html?o=OrderRef'  }";


        var response = client.PostAsync("https://secure.telr.com/gateway/order.json",
            new StringContent(JsonConvert.SerializeObject(str).ToString(),
                Encoding.UTF8, "application/json"))
                .Result;

        Response.Write(response);

        if (response.IsSuccessStatusCode)
        {
            dynamic content = JsonConvert.DeserializeObject(
                response.Content.ReadAsStringAsync()
                .Result);

            // Access variables from the returned JSON object
            var appHref = content.links.applications.href;
        }
    }


}

RESPONSE

StatusCode: 417, ReasonPhrase: 'Expectation Failed', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Connection: close Date: Tue, 17 Jan 2017 10:52:30 GMT Server: Apache Content-Length: 364 Content-Type: text/html; charset=iso-8859-1 }

I have changed return_auth & ivp_store as i cant share it. Any pointer to do it right would be of great help.

I am confused with there documentation so to do it right way. They dont seem to have any .net example on their website rather they have PHP Plugins which i don't understand.

I found another example for wooCommerce plugin which is in PHP

<?php


if (!defined('ABSPATH')) { exit; } // Exit if accessed directly
if (!defined('WP_CONTENT_URL')) { define('WP_CONTENT_URL', get_option('siteurl').'/wp-content'); }
if (!defined('WP_PLUGIN_URL')) { define('WP_PLUGIN_URL', WP_CONTENT_URL.'/plugins'); }
if (!defined('WP_CONTENT_DIR')) { define('WP_CONTENT_DIR', ABSPATH.'wp-content'); }
if (!defined('WP_PLUGIN_DIR')) { define('WP_PLUGIN_DIR', WP_CONTENT_DIR.'/plugins'); }

function telr_init() {
    /**
    * __construct function.
    *
    * @access public
    * @return void
    */
    class WC_Gateway_Telr extends WC_Payment_Gateway {

        public function __construct() {
            global $woocommerce;

            $this->min_wc_ver="2.3.8";
            $this->id = 'telr';
            $this->has_fields = false;  // No additional fields in checkout page
            $this->method_title = __('Telr', 'woocommerce');
            $this->method_description = __('Telr Checkout', 'telr-for-woocommerce');
            $this->order_button_text = __( 'Proceed to Telr', 'telr-for-woocommerce' );
            $this->woocom_ver = $woocommerce->version;

            // Load the settings.
            $this->init_form_fields();  // Config page fields
            $this->init_settings();

            if ($this->can_init()) {
                $preload='<iframe style="width:1px;height:1px;visibility:hidden;display:none;" src="https://secure.telrcdn.com/preload.html"></iframe>';
                $this->enabled          = $this->get_config_option('enabled');
                $this->title            = $this->get_config_option('title');
                $this->description      = $this->get_config_option('description').$preload;
                $this->store_id         = $this->get_config_option('store_id');
                $this->store_secret     = $this->get_config_option('store_secret');
                $this->testmode         = $this->get_config_option('testmode');
                $this->debug            = $this->get_config_option('debug');
                $this->order_status     = $this->get_config_option('order_status');
                $this->cart_desc        = $this->get_config_option('cart_desc');
                $this->form_submission_method   = true;
                $this->api_endpoint = 'https://secure.telr.com/gateway/order.json';

                // Actions
                add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options'));
                add_action( 'woocommerce_thankyou', array($this, 'update_order_status'));

            } else {
                $this->enabled = false;
            }

        }

        private function can_init() {
            if (version_compare(PHP_VERSION, '5.5.0') < 0) {
                return false;
            }
            if (!function_exists('curl_version')) { return false; }
            if (!function_exists('curl_init')) { return false; }
            if (version_compare($this->woocom_ver,$this->min_wc_ver) < 0) {
                return false;
            }
            return true;
        }


        public function update_order_status($order_id) {
            global $woocommerce;

            $order = new WC_Order( $order_id );
            $order_check = $this->check_order($order_id);

            if($order_check) {
                $new_status = $this->sorder_status;
                if (empty($new_status)) { $new_status="completed"; }
                $order->update_status($new_status);
            }
        }


        /**
        * Process the payment and return the result.
        *
        * @access public
        * @return array
        */
        function process_payment($order_id) {
            $order = new WC_Order($order_id);
            $result = $this->generate_request($order);
            $telr_ref = trim($result['order']['ref']);
            $telr_url= trim($result['order']['url']);

            if (empty($telr_ref) || empty($telr_url)) {
                wc_add_notice('Payment API Failure, Please try again.', 'error');
            } else {
                update_post_meta( $order_id, '_telr_ref', $telr_ref);
            }

            return array(
                'result'    => 'success',
                'redirect'  => $telr_url,
            );

        }

        public function generate_request($order) {
            global $woocommerce;

            $order_id = $order->id;

            $cart_id = $order_id."_".uniqid();
            $cart_desc=trim($this->cart_desc);
            if (empty($cart_desc)) { $cart_desc='Order {order_id}'; }
            $cart_desc = preg_replace('/{order_id}/i',$order_id,$cart_desc);

            $test_mode = ($this->testmode == 'yes') ? 1 : 0;
            $return_url = 'auto:'.add_query_arg('utm_nooverride','1',$this->get_return_url($order));
            $cancel_url = 'auto:'.$order->get_cancel_order_url();

            $data = array(
                'ivp_method'    => "create",
                'ivp_source'    => 'WooCommerce '.$woocommerce->version,
                'ivp_store' => $this->store_id ,
                'ivp_authkey'   => $this->store_secret,
                'ivp_cart'  => $cart_id,
                'ivp_test'  => $test_mode,
                'ivp_amount'    => $order->order_total,
                'ivp_currency'  => get_woocommerce_currency(),
                'ivp_desc'  => $cart_desc,
                'return_auth'   => $return_url,
                'return_can'    => $cancel_url,
                'return_decl'   => $cancel_url,
                'bill_fname'    => $order->billing_first_name,
                'bill_sname'    => $order->billing_last_name,
                'bill_addr1'    => $order->billing_address_1,
                'bill_addr2'    => $order->billing_address_2,
                'bill_city' => $order->billing_city,
                'bill_region'   => $order->billing_state,
                'bill_zip'  => $order->billing_postcode,
                'bill_country'  => $order->billing_country,
                'bill_email'    => $order->billing_email,
                );

            if (is_ssl() && is_user_logged_in()) {
                $data['bill_custref'] = get_current_user_id();
            }

            $response = $this->api_request($data);
            return $response;
        }

        public function check_order($order_id) {
            global $woocommerce;

            $order_ref = get_post_meta($order_id, '_telr_ref', true);

            $data = array(
                'ivp_method'    => "check",
                'ivp_store' => $this->store_id ,
                'order_ref' => $order_ref,
                'ivp_authkey'   => $this->store_secret,
                );

            $response = $this->api_request($data);

            $order_status_arr = array(2,3);
            $transaction_status_arr = array('A', 'H');

            if (array_key_exists("order", $response)) {
                $order_status = $response['order']['status']['code'];
                $transaction_status = $response['order']['transaction']['status'];
                if ( in_array($order_status, $order_status_arr) && in_array($transaction_status, $transaction_status_arr)) {
                    return true;
                }
            }
            return false;
        }

        public function api_request($data) {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $this->api_endpoint);
            curl_setopt($ch, CURLOPT_POST, count($data));
            curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
            $results = curl_exec($ch);
            curl_close($ch);
            $results = json_decode($results,true);
            return $results;
        }


        /* ------------------------------ Admin setting page ------------------------------------------------ */

        public function get_config_option($key) {
            return $this->get_option($key);
        }

        public function admin_options() {
            if ($this->can_init()) {
                $this->show_admin_options();
            } else {
                $this->not_available();
            }
        }

        public function not_available() {
            ?>
            <div class="inline error"><p><strong><?php _e( 'Gateway Disabled', 'woocommerce' ); ?></strong>: <?php _e( sprintf('Requires WooCommerce %s or later, PHP 5.5 or later, and PHP cURL',$this->min_wc_ver), 'woocommerce' ); ?></p></div>
            <?php
        }

        public function show_admin_options() {
            // Admin Panel Options
            $configured = true;
            if ((empty($this->store_id)) || (empty($this->store_secret))) { $configured=false; }

            ?>
            <h3><?php _e('Telr', 'woocommerce'); ?></h3>
            <?php if (!$configured) : ?>
                <div id="wc_get_started">
                <span class="main"><?php _e('Telr Hosted Payment Page', 'woocommerce'); ?></span>
                <span><a href="https://www.telr.com/" target="_blank">Telr</a> <?php _e('are a PCI DSS Level 1 certified payment gateway. We guarantee that we will handle the storage, processing and transmission of your customer\'s cardholder data in a manner which meets or exceeds the highest standards in the industry.', 'woocommerce'); ?></span>
                <span><br><b>NOTE: </b> You must enter your store ID and authentication key</span>
                </div>
            <?php else : ?>
                <p><?php _e('Telr Hosted Payment Page', 'woocommerce'); ?></p>
            <?php endif; ?>

            <table class="form-table">
            <?php $this->generate_settings_html(); ?>
            </table><!--/.form-table-->
            <?php
        }

        // Admin settings fields
        function init_form_fields() {
            // Initialise Gateway Settings Form Fields
            $this->form_fields = array(
                'enabled' => array(
                    'title'     => __('Enable/Disable', 'woocommerce'),
                    'type'      => 'checkbox',
                    'label'     => __('Enable Telr', 'woocommerce'),
                    'default'   => 'yes'
                ),
                'title' => array(
                    'title'     => __('Title', 'woocommerce'),
                    'type'      => 'text',
                    'description'   => __('This controls the title which the user sees during checkout.', 'woocommerce'),
                    'default'   => __('Credit/Debit card', 'woocommerce'),
                    'desc_tip'  => true,
                ),
                'description' => array(
                    'title'     => __('Description', 'woocommerce'),
                    'type'      => 'textarea',
                    'description'   => __('This controls the description which the user sees during checkout.', 'woocommerce'),
                    'default'   => __('Pay using a credit or debit card via Telr Secure Payments', 'woocommerce'),
                    'desc_tip'  => true,
                ),
                'cart_desc' => array(
                    'title'     => __('Transaction description', 'woocommerce'),
                    'type'      => 'text',
                    'description'   => __('This controls the transaction description shown within the hosted payment page.', 'woocommerce'),
                    'default'   => __('Your order from StoreName', 'woocommerce'),
                    'desc_tip'  => true,
                ),
                'store_id' => array(
                    'title'     => __('Store ID', 'woocommerce'),
                    'type'      => 'text',
                    'description'   => __('Enter your Telr Store ID.', 'woocommerce'),
                    'default'   => '',
                    'desc_tip'  => true,
                    'placeholder'   => '[StoreID]'
                ),
                'store_secret' => array(
                    'title'     => __('Authentication Key', 'woocommerce'),
                    'type'      => 'text',
                    'description'   => __('This value must match the value configured in the hosted payment page V2 settings', 'woocommerce'),
                    'default'   => '',
                    'desc_tip'  => true,
                    'placeholder'   => '[Authentication Key]'
                ),
                'testmode' => array(
                    'title'     => __('Test Mode', 'woocommerce'),
                    'type'      => 'checkbox',
                    'label'     => __('Generate transactions in test mode', 'woocommerce'),
                    'default'   => 'yes',
                    'description'   => __('Use this whilst testing your integration. You must disable test mode when you are ready to take live transactions')
                ),
                'order_status' => array(
                    'title'     => __('Order Status', 'woocommerce'),
                    'type'      => 'select',
                    'label'     => __('Order status for authorised payments', 'woocommerce'),
                    'default'   => 'processing',
                    'description'   => __('Set the WooCommerce order status that will be used for authorised transations', 'woocommerce'),
                    'options'   => array(
                        'processing'    => __( 'Processing', 'woocommerce' ),
                        'completed' => __( 'Completed', 'woocommerce' )
                    )
                )
            );
        }


    }
}



if(!function_exists('telr_list_network_plugins')) {
    function telr_list_network_plugins() {
        if (!is_multisite()) {
            return false;
        $sitewide_plugins = array_keys((array) get_site_option('active_sitewide_plugins'));
        }
        if (!is_array($sitewide_plugins)) {
            return false;
        }
        return $sitewide_plugins;
    }
}

function add_telr_gateway($methods) {
    $methods[] = 'WC_Gateway_Telr';
    return $methods;
}

// Add plugin to wordpress/woocommerce
if ((in_array('woocommerce/woocommerce.php', (array)get_option('active_plugins'))) || (in_array('woocommerce/woocommerce.php', (array)telr_list_network_plugins()))) {
    add_action('plugins_loaded', 'telr_init', 0);
    add_filter('woocommerce_payment_gateways', 'add_telr_gateway');
}
?>

I have 2 simple controls. When my page loads, it automatic fills up.

enter image description here

I got following reference which suggests to set Autocomplete = Off

Stop browser from filling textboxes with details

https://forums.asp.net/t/1107643.aspx?How+do+you+disable+history+info+on+a+textbox+

But it doesn't work. You can see above screenshot. It is email field which automatically filled by reference of cache when page loaded. It is going to be headache.

Can anybody please suggest me how to prevent this?

Please note, I don't want to clear history. I just want that this should not be filled up when my page loads.

I'm using this example here to render a Razor view with a mode that I pass it, and then send emails: https://weblog.west-wind.com/posts/2012/May/30/Rendering-ASPNET-MVC-Views-to-String

This is an example of how I send my email, and it works great when I have a HTTPContext:

var CustomEmailModel = new EmailBasicViewModel()
{
    CustomWebsite = ConfigurationManager.AppSettings["CustomWebsite"],
    CustomFriendlyWebsite = ConfigurationManager.AppSettings["CustomWeb"],
    CustomSupportEmail = ConfigurationManager.AppSettings["CustomSupportEmail"],
    CustomPhone = ConfigurationManager.AppSettings["CustomPhone"],
    EmailSubject = "This is the subject",
    EmailMessage = "This is a message"
};

string emailBody = ViewRenderer.RenderView("~/Views/Template/BasicEmail.cshtml", CustomEmailModel);
MailHelper.SendNotificationEmailFromCustom(emailRecipients, CustomEmailModel.EmailSubject, emailBody);

However, if I put something like this in a controller that I call, for example, from a Hangfire scheduled task, it throws an error:

ViewRenderer must run in the context of an ASP.NET Application and requires HttpContext.Current to be present

I think in the article Rick mentions that it may be possible to do this without having a HTTPContext by using something like this: https://github.com/Antaris/RazorEngine

I'm a bit stumped, so can anybody advise on the best way I can achieve this?

Thanks!

I have three radio buttons which all have hidden <div>'s under each of them (this radio button works if I didn't bind them to the model). If you click <div> one and decided to click a second radio button, it will hide the first one and this also applies to the other one.

However, each radio button has its own functionality which it will perform. So on the controller I have an If-statement for each radio button. After I have bound each radio button to the model, they no longer work and they don't get de-selected when I select another radio button and no longer hide <div>'s. I am not sure if there's something I am missing. Thanks.

    Razor Code

     <div class="form-group" style="margin-left: 165px;">    
        <div class="radio-inline">
            @Html.RadioButtonFor(model => model.Isrd1, "one",true, new { id = "id1" }) Radio One
        </div>

        <div class="radio-inline">
            @Html.RadioButtonFor(m => m.Isrd2, "two", new { id = "id2" })Radio two
        </div>

         <div class="radio-inline">
            @Html.RadioButtonFor(m => m.Isrd3, "three", new { id = "id3" })Radio three
        </div>
    </div>

My model:

    public class ModelSelection
    { 
         public string Types { get; set; }

         public string Isrd1 { get; set; }
         public string Isrd2 { get; set; }
         public string Isrd3 { get; set; }
    }

My controller:

     if (md.Types == "one")
     {
     }

     if (md.Types == "two")
     {
     }

     if (md.Types == "three")
     {
     }

My JavaScript:

          $('input[name=Isrd1]').click(function () {
                if (this.id == "id1") {
                    $("#div1").show('slow');
                    $("#div2").hide('slow');
                    $("#div3").hide('slow');
                }
            });

             $('input[name=Isrd2]').click(function () {
                if (this.id == "id2") {
                    $("#div2").show('slow');
                    $("#div1").hide('slow');
                    $("#div3").hide('slow');

               $('input[name=Isrd3]').click(function () {
                if (this.id == "id3") {
                    $("#div3").show('slow');
                    $("#div1").hide('slow');
                    $("#div2").hide('slow');

How to display tooltip for textbox while user entering value using asp.net mvc without using jquery/client script? I tried using @Html.TextBoxFor and title. but it was not working.

I have a SelectList that populates / works ok.

I have a new Requirement to disable the list for certain users. So I added in a new property to the ViewModel, LockSelectList. this property is set in the controller (and works).

However, when the list is rendered, it is always disabled.

I have tried

@Html.DropDownListFor(x => x.Id,  Model.AllLocations, new {disabled = Model.LockLocationList? "true" : "false" })

@Html.DropDownListFor(x => x.Id,  Model.AllLocations, new {disabled = Model.LockLocationList? "disabled" : "false" })

@Html.DropDownListFor(x => x.Id,  Model.AllLocations, new {disabled = Model.LockLocationList? "disabled" : "" })

but none work. they all render correct html, but it seems that the presence of the disabled attribute, no matter the value disables the list. So what do I tweak to the code make this work? (Preferably without using jQuery to handle the enable / disable after the event)

this might be an easy problem to solve, or not, but it's hard to explain and put into google so I couldn't find a solution.

In my database I have multiple rows and column with different data and a few have the same date, so I want to do a foreach loop that reads all the data from a single date, sums that all up and puts it into a variable, (this part I know how to do), but after all this is done in one loop, on the next loop around I want it to be the next day.

I'm wondering if this is possible? I guess you could do a i++ kind of thing but that wouldn't work when going from the 31st to 1st the next month I guess.

Does anyone know of a solution to this problem?

I'm working on project and after i select data from the database and put it into sqldatareader and trying to post it in some labels i figured that all of the labels print the same value because the sqldatareader has only one column with many values how can i print those values ??

i have a problem .i want too get the IP and name of the PC in which the staff logged in(the staff can logging through any system in the office )and i want to set alarm for the particular PC. i want the c# code for my hospital management system. please help me

I have 2 type notifications for users. I want to post all of them in same page. I need 2 repeater for different data and different styles. But there is a problem; notifications must be shown depends on date. (Both data source have SDATE column) I mean, i need date sorting for them. So how can i do that? Any advice? *I'm posting an image for explain my problem, please check it out. Thank you. ProblemExp.

I have a string which looks something like this:

some text [different text]

Using C# is it possible to insert some html tags so that resulting string would be

some text [<b>different text</b>]

It would have to cope with instances where there are no square brackets?

Thanks.

I downloaded a working MVC project to learn the actual MVC coding. On direct build, it gave me errors, I searched the net and as per suggestions I updated all the nuget packages and the other updates available. Now Razor is updated to 3.0, MVC to 5.2.3.0, Visual Studio to its latest version of VS 2012, and there is no intellisense anywhere on my project. I tried updating the web config with various values as suggested by users. I also tried updating the GUID. I created a fresh MVC 4 project and tried multiple times, but ended up updating the files and eventually back to Step 1. Its a hair pulling story now, as i cannot manage to get intellisense and all my work is stalled. Please help

I'm working for a telecommunication company and I was told to re program an existing SMS Gateway which is written in Java Spring,JMS.That program has some drawbacks in database structure and workflow and I have to restructure the process and program it in C# instead of Java.Can I know the steps I must follow and what kind of technologies must be used to create a SMS Gateway from scratch.

  1. A .net program is implemented to handle API requests and it stores data to OUTBOX table.(receiver number, message text etc.)

  2. Then Java spring program is running as a service and send the outbox messages to receivers using a business logic. But when We send bulk messages there is a 2 minutes delay.

I have an application in which an user can edit a form. This is my code :

Controller and ViewModel :

public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }

    [HttpPost]
    public ActionResult Edit(MyGlobalObject MyGlobalObject)
    {
        MyGlobalObject.Save();
        return View();
    }
}

public class MyGlobalObject
{
    public MyObjectToEdit MyObjectToEdit { get; set; }        
}

public  class MyObjectToEdit
{
    public int MyProperty { get; set; }

    public string MyProperty1 { get; set; }

    public bool MyProperty2 { get; set; }
}

My razor view :

@model TestAppliWeb.Controllers.MyGlobalObject

@using (Html.BeginForm("Edit", "HomeController"))
{
    @Html.AntiForgeryToken()
    @Html.EditorFor(m => m.MyObjectToEdit)
}

Everything is working well. But I would like to bring a new feature to this form, depending a certain condition, itself depending of MyProperty2 of MyObjectToEdit, I would like to continue to display the form but disabled it : all the form must be displayed to the user but he cannot edit anything and click on save.

If MyProperty2 is true, the form continue to be editable, if not, the form must be disabled. But I don't know how to impact it with a minimal of code in my razor view the rendering of the form. I have a solution, but it seems too "unclean" : I disabled all the elements of the form with javascript and css.

Is there any mvc html helper or anything like this to write in the razor view to disable the form.

Thanks in advance for your help

I'm having this error and scavenged S.O. for answers. I used the [childonly], added the controller to my renderaction. I was able to submit but once I added validationmessagefor. This exception came up.

Here's the partial View


<div class="panel panel-default">
    <div class="panel-heading">
        <h4 class="panel-title">
            <a data-toggle="collapse" data-parent="#accordion" href="#Draft">
                My Drafts
            </a>
        </h4>
    </div>
    <div id="Draft" class="panel-collapse collapse">
        <div class="panel-body">

            @{
                Html.RenderAction("GetDrafts","MyPostController");
            }

        </div>
    </div>
</div>
      <div class="row">
                <div class="col-md-5">
                    <label>Reply To:<small>(optional)</small></label>
                </div>
                <div class="col-md-7"> 
                    @Html.TextBoxFor(m => m.ReplyTo,null,new { @class = "form-control" })
                    @Html.ValidationMessageFor(m => m.ReplyTo)

                </div>


            </div>

on top of that there's a

 @using (Html.BeginForm())
  {

   @Html.AntiForgeryToken()

 <div class="col-md-3">
    @*//side menu here*@
    @Html.Partial("_SideMenu", Model) 

</div>

here's the action

    /// <summary>
    /// get all saved drafts
    /// </summary>
    /// <returns></returns>
    [ChildActionOnly]
    public ActionResult GetDrafts()
    {
        var drafts = _dbrepo.GetUserDrafts();
        return PartialView("_DraftView", drafts);
    }

So as I have mentioned. I was able to post data if modelstate isvalid. but once it is invalid. that exception comes up. I tried commenting the renderaction for testing. and I was able to throw the validationmessage.

I am working on a web-forms based project in asp.net 4.6 and using bootstrap3. I want to show all asp: drop-down items in bold.

I have form-control class applied to asp:drop down list

I have registered my APP on Instagram and i Successfully retrieved recent media using: https://api.instagram.com/v1/users/self/media/recent/?access_token=ACCESS-TOKEN

Now I want to Subscribe user to instgram to get real time update , i tried this :

        $.ajax({                                                                   
            url: "https://api.instagram.com/v1/subscriptions/?client_id=MyClientID&client_secret=MyClientSecret&object=user&aspect=media&verify_token=MyToken&callback_url=MyService.ashx",
            type: 'POST',
            dataType: "jsonp",
            success: function (data) {
                console.log(data);
            },
            error: function (errorText) {
                console.log(errorText);
            }
        });

    });

the Post request above prints : {"meta": {"code": 200}, "data": []} which means it is a successful request

but i didn't receive any request from Instagram on my callback URL to send me the [ hub.challenge ]

Instagram subscription API :

Create a Subscription

To create a subscription, you make a POST request to the subscriptions endpoint.

enter image description here

Where I went Wrong ??