Hi there is a Telerik grid. and inside it there are two textBox Columns named sign in time and sign out. finally there is a label column too, to have the hours from the time signed in to sign out. that should be calculated and shown as other two textBox values change. What should i do ? below js function is called in onkeypress of txtsignout textbox

var grid = $find("<%= rdgDriverTimeSheets.ClientID %>");
                    if (grid) {

                            var MasterTable = grid.get_masterTableView();
                            var Rows = MasterTable.get_dataItems();
                            for (var i = 0; i < Rows.length; i++) {
                                var row = Rows[i];

                                var signIn = row.findControl("txtSignIn").get_value();
                                //var signOut = args.get_keyCharacter();
                                var signOut = row.findControl("txtSignOut").get_value();
                                // var hours = signOut - signIn;
                                //row.findControl("lblHours").set_value(hours)
                        }

this is my grid

Category column1 column2 total row1 1 2 3 row2 1 0 1 total 2 2 4

I only able to get value to calculate at column[0] but not start it from column[1]. What did I miss out in this ?

Dim totalrow = ExportDT.NewRow For Each col As Data.DataColumn In ExportDT.Columns

            For n_Loop As Integer = 1 To ExportDT.Columns.Count - 1
                 Dim colname As Integer = col.ColumnName[n_loop]

                totalrow(col.ColumnName) = Convert.ToDouble(ExportDT.Compute("SUM(" & colname & ")", "nothing"))
            Next
        Next

        ExportDT.Rows.Add(totalrow)

I am trying to post some signup form fields via CURL and PHP in .aspx site. I find the onclick event in the Register button.

<a onclick="return Page_ClientValidate('vg_registration');" id="dnn_ctr949_View_ctrl_notLoggedIn_registerCtrl_lb_register" class="button_black" href="javascript:__doPostBack('dnn$ctr949$View$ctrl_notLoggedIn$registerCtrl$lb_register','')">Register</a>

MY PHP CURL CODE TO POST FIELDS ARE AS FOLLOWS

**<?php
// Login information
$salutation = '1';
$password = '1234567';
$password_repeat = '1234567';
$fname="John";
$lname="William";
$email="william2022@gmail.com";
$street="14 decres lane";
$city="Delhi";
$country="IND";
$mphone="8012345676";
$postal="400145";
$utcoffset = '-6';
$cookiefile = 'ticket/cookies.txt';
$client = new Login($cookiefile);
// Retrieve page first to store cookies 
$page = $client -> get("http://www.websitename.com/my-account/register");
// scrape __VIEWSTATE value
preg_match('~<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="(.*?)" />~', $page, $viewstate);
preg_match('~<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="(.*?)" />~', $page, $eventvalidation);
$viewstate = $viewstate[1];
$eventvalidation = $eventvalidation[1];
$form_data = array(
    '__EVENTTARGET' => '',
    '__EVENTARGUMENT' => '',
    '__VIEWSTATE' => rawurlencode($viewstate),
     '__EVENTVALIDATION' => rawurlencode($eventvalidation),
    'dnn$ctr949$View$ctrl_notLoggedIn$registerCtrl$ddl_salutation' => $salutation,
    'dnn$ctr949$View$ctrl_notLoggedIn$registerCtrl$tb_firstname' => $fname,
    'dnn$ctr949$View$ctrl_notLoggedIn$registerCtrl$tb_lastname' => $lname,
    'dnn$ctr949$View$ctrl_notLoggedIn$registerCtrl$tb_email' => $email,
    'dnn$ctr949$View$ctrl_notLoggedIn$registerCtrl$tb_password' => $password,
    'dnn$ctr949$View$ctrl_notLoggedIn$registerCtrl$tb_password_repeat' => $password_repeat,
    'dnn$ctr949$View$ctrl_notLoggedIn$registerCtrl$tb_street' => $street,
    'dnn$ctr949$View$ctrl_notLoggedIn$registerCtrl$tb_postalCode' => $postal,
    'dnn$ctr949$View$ctrl_notLoggedIn$registerCtrl$tb_city' => $city,
     'dnn$ctr949$View$ctrl_notLoggedIn$registerCtrl$ddl_country' => $country,
     'dnn$ctr949$View$ctrl_notLoggedIn$registerCtrl$tb_mobile' => $mphone,
     //'dnn$ctr949$View$ctrl_notLoggedIn$registerCtrl$lb_register' => ''
);
print_r($form_data); 
// Do our actual login
$page = $client -> get("http://www.websitename.com/my-account/register", $form_data);
//echo $page;
// cURL wrapper class    
class Login {
    private $_cookiefile;
    public function __construct($cookiefile) {
        if (!is_writable($cookiefile)) {
            //throw new Exception('Cannot write cookiefile: ' . $cookiefile);
        }
        $this -> _cookiefile = $cookiefile;
    }
    public function get($url, $data = false) {
        // Setup cURL
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);

        curl_setopt($ch, CURLOPT_ENCODING,"UTF-8");
        curl_setopt($ch, CURLOPT_VERBOSE, 1);
        //curl_setopt($ch, CURLOPT_REFERER, $referer);
        curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:11.0) Gecko/20100101 Firefox/11.0' );
        curl_setopt($ch, CURLOPT_COOKIEFILE, $this -> _cookiefile);
        curl_setopt($ch, CURLOPT_COOKIEJAR, $this -> _cookiefile);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
        curl_setopt($ch, CURLOPT_TIMEOUT,120);
        //curl_setopt($ch, CURLOPT_MAXREDIRS, 10);

        // Is there data to post
        if (!empty($data)) {
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
            //curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
            //echo http_build_query($data);


         }


    $repsonse=curl_exec($ch);

     $err = curl_errno($ch);
    $errmsg = curl_error($ch) ;
    $header = curl_getinfo($ch);

    print_r( $header);

    curl_close($ch);
        return $repsonse;

    //curl_close($ch);
    }
}
?>**

I am getting error from the remote server :-

A critical error has occurred. Please check the Event Viewer for further details . 

I have captured the _viewstate and _eventvalidation properly and pass the value into post parameters along with other parameters.
But it is not posting any fields. I am not able to make out where the problem lies actually.
Is the remote server recognizing bot?

You may also consider the part of the following output for better understanding (after posting fields the following header is printed) :

Array ( [url] => http://www.websitename.com/Default.aspx?tabid=184&
error=An%20unexpected%20error%20has%20occurred&content=0 [content_type] => text/html;
charset=utf-8 [http_code] => 200 [header_size] => 1477 [request_size] => 1100 
[filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 1 [total_time] => 
1.072382 [namelookup_time] => 4.0E-5 [connect_time] => 0.081338 [pretransfer_time] => 
0.081449 [size_upload] => 0 [size_download] => 65573 [speed_download] => 61147 
[speed_upload] => 0 [download_content_length] => 65573 [upload_content_length] => -1 
[starttransfer_time] => 0.260364 [redirect_time] => 0.563111 [certinfo] => Array ( ) 
[redirect_url] => )

Would be a gr8 help if someone can show me a silverline in the problem. Thanks Krish

I have written one code Using property in text box i am setting some values like this

public string Color

{ 

get{}; 

set
  { 

     SetColor(value);

  } 

} 

private void SetColor(string level)
{

    switch(level.ToLower())
    {

     case "high":

     textbox1.BackColor = System.Drawing.Color.Red;

     break;

     case "medium":

     textbox1.BackColor = System.Drawing.Color.Green;

     break;

     case "low":

     textbox1.BackColor = System.Drawing.Color.Yellow;

     break;

   }

}

But my main aim is i need to set flag , if the flag is High it should show red font similarly if the flag is medium it should show yellow font in label.

public static class EnumExtensions
{
    private static void CheckIsEnum<T>(bool withFlags)
    {

            CheckIsEnum(T) (True);
    }
}



 public static bool IsFlagSet<T>(this T value, T flag)
{



}

Will I need to Use a pipe symbol while setting flag variable? I was surfing this on net, but I get answers which is not I am expecting. One one flag Boolean true or false. IKf the flag is true the color font should be enable according. Also please help me on I need to get data from data base. will it be possible and see whether the particular value has high ,low or medium risk and display font accordingly

Could anyone advice me how to embed the above code in the flags using enum.

I want this web application. please help me how to resolve this.

I have some problems understanding mvc in php.

My folder structure looks like this:

controller
|- member.php
model
|- member.php
view
|- overview.php

My code looks like this:

controller > member.php

include '../model/member.php';

class Member{
    public function create_table_of_all_members(){
        $model = new Member();

        $members = $model->get_all_members();

        foreach ($members as $member) {
            echo $member;
        }
    }

    public function create_form(){

    }
}

model > member.php

class Member{
    public function __construct()
     {
        // DB-Connection initialization
     }

    function getAllMembers(){
        $sql = "";
        return $result;
    }
}

view > overview.php

include '../controller/member.php';

$controller = new Member();
$controller->create_table_of_all_members();

Am I on the right way? In the view folder I would put e.g overview (all pages with a table), form (all pages with a form)..

I want to implement a cache functionnality for cakephp 2.5.3, related to find queries, but I want to invalidate cache on all events related to the tables (update, delete, ...). I coded this into AppModel.php, can you tell me what do you think about the code logic and efficiency ? Thanks.

public function find($conditions = null, $fields = array(), $order = null, $recursive = null) {
    $keyName = sha1(serialize(func_get_args()));
    if (Cache::read($this->table . '_' . $keyName, '5m') !== false) {
        $this->log('read cache ' . $this->table . '_' . $keyName);

        return Cache::read($this->table . '_' . $keyName, '5m');
    } else {

        $data = parent::find($conditions, $fields, $order, $recursive);
        Cache::write($this->table . '_' . $keyName, $data, '5m');
        $this->addToCacheList($keyName);
        $this->log('add ' . $this->table . '_' . $keyName);

        return $data;
    }
}

public function afterSave($created, $options = array()) {

    $this->flushCacheList();

    parent::afterSave($created, $options);
}

public function afterDelete() {

    $this->flushCacheList();

    parent::afterDelete();
}

public function addToCacheList($keyName) {
    if (Cache::read($this->table, '5m') !== false) {
        $values = Cache::read($this->table, '5m');
        $values[] = $keyName;
    } else {
        $values = array($keyName);
    }

    Cache::write($this->table, $values, '5m');
}

public function flushCacheList() {
    if (Cache::read($this->table, '5m')) {
        $values = Cache::read($this->table, '5m');
        foreach($values AS $value) {
            Cache::delete($this->table . '_' . $value, '5m');
            $this->log('flush ' . $this->table . '_' . $value);
        }
        Cache::delete($this->table, '5m');
    }
}

I'm writing a simple Java Swing GUI application following the MVC design pattern. I've got a MainFrame.java which instantiates LoginDialog.java (modal JDialog). The user then logs in with username and password or can register (by clicking on Jbutton) which instantiates RegisterDialog.java (JDialog instantiated from LoginDialog). I've also got a Controller.java class which connects to a Database.java, and allows interaction with database. MainFrame object can interact with Database through controller object. On the RegisterDialog, when the user presses submit, I want to verify that the username is not already taken. How can I get data from Database from RegisterDialog? Also how can I get data from LoginDialog (should I have MainFrame listen to a DataRequestEvent that would be fired from LoginDialog?)

public class Controller {
    private Database db;
    public Controller(){
    db = new Database();
    }
}
public class MainFrame extends JFrame{
    private LoginDialog loginDialog;
    private Controller controller;
    public MainFrame(){
        controller = new Controller();
        loginDialog = new LoginDialog();
        loginDialog.setVisible(true);
        //...
    }
}
public class LoginDialog extends JDialog{
    //form fields...
    private JButton regBtn;
    private RegisterDialog registerDialog;
    public LoginDialog(){
        registerDialog = new RegisterDialog();
        regBtn = new JButton("Register");
        regBtn.addActionListener(new ActionListener(){
            registerDialog.setVisible(true);
        });
    }
}

public class RegisterDialog extends JDialog{
    //...
    private JButton submitBtn;
    public RegisterDialog(){
        submitBtn = new JButton();
        submitBtn.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                validateUsername();
            }
        });
    }
    public void validateUsername(){
        //here I need to check whether username is already in DB (sqlite)
    }       
}

My app (like most apps) uses the query string to pass state data from page to page. But lately, some users have been tampering with query string variables. I want to prevent this by adding a checksum to every querystring in the app, so that I can validate the checksum on each request and reject the tampered ones.

I've got a method that creates the secured query string, but I don't want to manually apply it to every href in my site, because there are thousands of them, including many in aspx pages, where the syntax is especially messy.


So, I'd like to use Response filtering to catch each page just before it's sent to the browser, and to replace all the href attributes with secured versions. I know how to do this, and I'm aware that there could be some performance implications, but are there any other reasons why this is not a good idea? Are there any gotchas I should be aware of? Is there a better way to secure query strings site wide, without doing each one manually, or a good reason why I'd better do it manually after all?

We have ASP.NET code that runs fine on Windows 2008, but on Windows 2012 (on an Azure VM) it's deleting the session variables on a redirect:

Login loggedInUser = StoreV2Entities.Current().Logins.Include(a => a.Account).SingleOrDefault(l => l.UserName == UsernameTextbox.Text);
Session["login"] = loggedInUser;
Response.Redirect("~/apps/UserCart.aspx?register=1", false);

Is there some way to make this work?

thanks - dave

I am sunning VS2012 and trying to debug an SQL server locally via Internet explorer. When I run the debug I get the error "Unhandled exception at line 118, column 17 in 52744/Default.aspx of localhost" (I slightly reworded this to avoid a no localhost in links error and submit)

0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'tablesorter'

In a Default.aspx window that closes if I stop debugging even after I select keep open and pin it. If I continue past this exception or if I try to debug in firefox or chrome I go to the web lofgin of the SQL server which logs in in fine online before changes still but when I log in under any of the three browsers in debugging I get a

"server error in '\' application

Login failed. The login is from an untrusted domain and cannot be used with Windows authentication."

followed by "Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below."

and a large, difficult to follow stack trace about the login coming from an untrusted domain.

My connection string in my web.config is

<add name="LocalSqlServer" connectionString="data source=127.0.0.1;Initial Catalog=ming_com;Integrated Security=SSPI; Max Pool Size=200; Connection Timeout=30" providerName="System.Data.SqlClient"/>

and I have tried replacing "Integrated Security=SSPI" with "Trusted_Connection=Yes" as well as an SQL username and password.

I need this help to finish adding field to 4 SQL tables in C# and check them back in to a TFS server. Does anyone know how to resolve this?

I am creating a web service (WCF) that can be added as a service reference to an existing ASP.NET website. I've created the web service as a website project that uses the service as a DLL extension following this tutorial: http://www.codeproject.com/Articles/531332/Implementing-a-Basic-Hello-World-WCF-Service-v

The web service is going to be hosted on an intranet web server that requires the use of HTTPS. I can browse to the web service and get the wsdl via web browser, but when I try to run any of the methods from the service, I get:

The remote server returned an error: (401) Unauthorized.

I guess I am just confused on how to properly setup the web service on IIS so that it uses Windows authentication. Also I am not sure once I have it using Windows Authentication, where do I setup the access restrictions?

Here's what my web.config looks like for the web service so far:

  <?xml version="1.0"?>

  <!-- root node -->
  <configuration>

    <!-- Default configuration from Website template -->
    <system.web>
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
    </system.web>

    <!-- Configuration code for WCF Service -->
    <system.serviceModel>

      <!-- specify hosting environment -->
      <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
        <!-- 
          Specify service name and its relative address.
          Allows you to define virtual service activation settings that map WCF Service types.
          Makes it possible to activate services hosted in WAS/IIS without a .svc file.
        -->
        <serviceActivations>
          <add factory="System.ServiceModel.Activation.ServiceHostFactory"
           relativeAddress="~/ADUserMaintenanceService.svc"
           service="ADUserMaintenanceService.ADUserMaintenanceService"/>
        </serviceActivations>
      </serviceHostingEnvironment>

      <!--BINDINGS-->
      <bindings>
        <basicHttpsBinding>
          <binding name="BasicHttpsBindingConfig">
            <security mode="Transport">
              <transport clientCredentialType="Windows" proxyCredentialType="Windows" />
            </security>
          </binding>
          <binding name="mexHttpBinding">
            <security mode="Transport">
              <transport clientCredentialType="Windows" proxyCredentialType="Windows" />
            </security>
          </binding>
        </basicHttpsBinding>
      </bindings>

      <!--BEHAVIORS-->
      <behaviors>
        <!--SERVICE BEHAVIORS-->
        <serviceBehaviors>
          <behavior name="ServiceBehaviorConfig">
            <!-- 
              Enables service metadata exchange for the service.
              Essential to let other applications locate the metadata of this service via HTTP. 
              Without the metadata, client applications can't generate the proxy and thus won't be able to use the service. 
            -->
            <serviceMetadata httpsGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="true" />
          </behavior>
        </serviceBehaviors>

        <!--ENDPOINT BEHAVIORS-->
        <endpointBehaviors>
          <behavior name="EndpointBehaviorConfig">
          </behavior>
        </endpointBehaviors>
      </behaviors>

      <!--SERVICES-->
      <services>
        <service name="ADUserMaintenanceService.ADUserMaintenanceService" behaviorConfiguration="ServiceBehaviorConfig">
          <endpoint address="" binding="basicHttpsBinding" contract="ADUserMaintenanceService.IADUserMaintenanceService" 
              name="BasicHttpsEndpoint" behaviorConfiguration="EndpointBehaviorConfig" bindingConfiguration="BasicHttpsBindingConfig" />
          <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
        </service>
      </services>
    </system.serviceModel>

  </configuration>

And here is the web.config for the asp.net website after I've added the service as a reference (automatic from Visual Studio):

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpsEndpoint">
                <security mode="Transport">
                    <transport clientCredentialType="Windows"/>
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://mydomain.com/ADUserMaintenanceService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpsEndpoint" contract="ADUserMaintenance.IADUserMaintenanceService" name="BasicHttpsEndpoint"/>
    </client>
</system.serviceModel>

In IIS, the web service has the following authentication options set:

Anonymous Authentication: Enabled ASP.NET Impersonation: Enabled Windows Authentication: Enabled

the rest are disabled.

The asp.net website I am hooking into is currently using only Windows Authentication and the App Pool is running as a proxy account. The app pool for the web service is just using application pool identity (default).

This security stuff is way over my head, the code works great, but configuring IIS is taking up 10x as long as coding this service did. Any help would be appreciated, as I can't seem to get anything out of msdn's documentation.

We have a web application that renders a script reference to webresource.axd.

src="/WebResource.axd?SOMELONGQUERYSTRING"

The problem is that the reference is to the root folder of the web application. However, when deployed, the browser does not have access to reference anything in that folder, as that would be the root folder of the domain, which is not owned by our company. The only access is through proxies that point to some subfolders of the root of our web application. Is there any way I can change the location of the reference to WebResouce.axd, and have the web application handler receive it? Or can i create a static version of the script it produces and link to that statically?

I have searched the net and it seems that the above is not a possibility. But can this be true, that we are forced to give browsers access to the root of the web application?

We are using .net 4.5.

Thank you very much in advance Jihad Haddad

I am pulling all users from a SQL Server DataTable and displaying that list in a table (See Code)

Controller Code:

Function Display Users() As ActionResult

Using db as new xDataContext

Dim model As New dataViewModel With { _
                                      .AllUsers = db.GetAllUsers() _
                                      }

            Return View(model)

        End Using

Model Code:

Public Function GetAllUsers() As List(Of User)
    Dim allusers = From user In Me.Users Select user Order By user.LastActivityDate Descending
    Return allusers.ToList()
End Function

HTML Code:

<table>
    <thead>
        <tr>
            <th>User/<>
            <th>Total Points</th>
        </tr>
    </thead>

    <tbody>

        <% For Each item in Model.AllUsers%>

            <tr>
                <td><%: item.UserId%></td>
                <td>NEED HELP HERE I want to show points from a separate table summed life to date </td>
            </tr>
        <% Next%>
    </tbody>
</table>

UserId's are stored in a user datatable and I can get those records easily. Points are stored in a separate table by date. What I am trying to get is the total number of points by summing all of the points for each user and displaying it in the table. This may be easily solved and I am just being dense...

I have searched for ways to accomplish this to no avail. Any help in doing this is appreciated.

Thank you for the quick reply. I am sorry I did not give enough info. I have two tables: Users and Activities - Activities contains points per activity that I want to sum life to date by user in the table. They are separate and I want to combine them in the View Table.
Example: User Points Ted 127 Sam 211

Thank you!

Right now I am displaying a clock (Hour: Minute + Date) on the aspx page using updatepanel and timer, it causes server side post back every 30 seconds which not a good thing, how can I do it using javascript or something simpler?

    <asp:UpdatePanel ID="UpdatePanelClock" runat="server">
        <ContentTemplate>
             <asp:Label ID="lblTime2" runat="server"></asp:Label>
         </ContentTemplate>
         <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Timer2" EventName="Tick" />
         </Triggers>
   </asp:UpdatePanel>

    <asp:Timer ID="Timer2" runat="server" Interval="30000" OnTick="Timer2_Tick"></asp:Timer>

Code behind

protected void Page_Load(object sender, EventArgs e)
   {
    if (!Page.IsPostBack)
      {
         lblTime2.Text = DateTimeOffset.Now.ToString("hh:mm tt") + " - " + DateTimeOffset.Now.ToString("dddd, MMMM dd");
      }
   }

I am using a software in PHP using Yii Framework, It works normally, but when I save a model, using the intruction $model->save(), in the database this instruction insert 2 or 3 register of the same $model. In the begining I thought it was a problem of the code, but I discover it is a problem of the Browser because in the Mosilla Browser that I have the software works normal, it only fail in Goggle Chrome and in Internet Explorer.

I have a form with several different tabs. The main tab has all main information about the person and the rest of the tabs are composed of several lists.

One of the tabs have a list of all comments related to that person. That tab also has a button that allows the user to insert a new comment.

What I do is make an ajax call and load the create view, replacing the list with the view. Something like this.

$("#btnNewAnnotation").click(function (e) {
        $.ajax({
            url: "/Annotations/Create",
            cache: false,
            data: { personId: $("#personId").val(), withouLayout: true },
            type: "GET",
            success: function (data, textStatus, jqXHR) {
                alert("alert of success!!");
                $("#annotationContent").html(data);
            },
            error: function (statusText, errorText) {
                alert(errorText);
            }
        });
    });

Now the Controller what it does it dump a partial view allowing me to put the new HTML on the annotationContent div

 public ActionResult Create(string personId, string withouLayout)
    {
        ViewBag.AnnotationTypeId = new SelectList(db.annotationtypes, "AnnotationTypeId", "Name");
        annotations annotation = new annotations();
        annotation.PersonId = personid;

        return PartialView(annotation);
    }

this all works really nice and without any problem. The problem I'm having is after inserting the comment in the database. What I want to do is reload the list with all comments again, but only update the div annotationContent

I have the following ajax

$("#createAnnotationForm").on("submit", function () {
        e.preventDefault();
        $.ajax({
            url: "/Annotations/Create",
            cache: false,
            data: $(this).serialize(),
            dataType: "json",
            type: "POST",
            success: function (data, textStatus) {
               //This alert never gets Called!!
                alert("ajax insert success");
            },
            error: function (statusText, errorText) {
                alert('Error: ' + errorText)
            }
        });
    });

the reason I do this is because the are multiple forms on the view and I only want to submit this form. My controller has the following

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(annotations annotations)
{
    try
    {
        db.annotations.Add(annotations);
        db.SaveChanges();
    }
    catch(Exception ex)
    {
    }

    return PartialView(db.annotations);
 }

When I submit the form, I get the error

The model item passed into the dictionary is of type 'System.Data.Entity.DbSet`1[RecruitmentWeb.Models.annotations]', but this dictionary requires a model item of type 'RecruitmentWeb.Models.annotations'.

I understand why I get this error but I don't know how I can reload my List of comments without reloading the entire page. Anyone has any idea?

I'm having an issue with some usercontrols.

This was a website created in vs 2010. When I installed vs 2013 and opened the website it created a website project for the website.

However now I can't run the website locally. it throws the error.

Error   22  The name 'AddEntity1' does not exist in the current context 

But since this isn't a project but a website I can't right click on the file and do the convert to website trick to build a designer file. There are no designer files.

When I upload to the website everything works like it should. But I can't test locally.

Any thoughts?

I want to bind json data to listview Like below but i don't know how ?

this is my content page:

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ListView ID="listViewMessages" runat="server" DataKeyNames="MessageID" ItemType="modelPD.Messagetbl">
    <ItemTemplate>
        <div class="Message">
            <div class="Title">
                <div class="Name">
                    <%#Item.Name %>
                </div>
                <div class="DateTime">
                    <%#Item.DateOfMessage %>
                </div>
            </div>
            <div id="MessageBody" runat="server" class="messageBody"><%#Item.MessageBody %></div>
            <div class="DivSending">
                <asp:LinkButton ID="linkButtonDelete" Text="Delete" CommandArgument='<%#Item.MessageID%>' OnCommand="linkButtonDelete_Command" runat="server" />
            </div>
        </div>
    </ItemTemplate>
</asp:ListView>
<div id="div" style="width: 200px; height: 200px; border: 1px solid red;"></div>
<script>
    $("#div").click(function () { UpdateListView();});
    function UpdateListView() {
        var Option = {};
        //alert("in Update function");
        Option.url = "/Admin/WebForm1.aspx/GetMyMessages";
        Option.type = "POST";
        Option.data = null;
        Option.contentType = "application/json/:charset:utf-8";
        Option, datatype = "json";
        Option.success = function () { $('#' + '<%=listViewMessages.ClientID%>'). }; //What Sould i do here?
        Option.error = function () { alert("error"); };
        $.ajax(Option);
    };
</script>

code behind :I read my messages and return that to client side .it will be send as json format.

    [WebMethod]
    public static List<Messagetbl> GetMyMessages()
    {
        using (MyEntities me = new MyEntities())
        {
            int UserId = UsersClass.UserId;//Get user id from session
            List<Messagetbl> listOfMessage = (from m in me.Messagetbl where m.receiverId == UserId select m).ToList();
            return listOfMessage;
        }
    }

I don't khow how to bind this List to ListView.does any one can help me?

I have a custom authorize filter that is on the controller and on some of the actions. The ones on the actions have parameters where the controller filter does not. So, I want the controller filter to apply only to the ones that do not have that same filter with parameters. I tried putting it on both places but the filter is called twice

    [CustomAuthorize]
    public class Controller
    {

        public ActionResult Index()
        {
            return View();
        }
        [CustomAuthorize(param1 ="123")]
        public ActionResult Index2()
        {
            return View();
        }

In the snippet above it calls customauthorize twice once with no parameters and second with parameters.

How do i prevent the first customauthorize if the action already has a customauthorize?

I have a winform MVC program that binds forms with a class.

I have a class "Command" which has several attributes like "name" "lastname" etc.

If I update it's property this way:

_command.name = "name";
_command.lastname = "lastname";

it works.

But if I update it this way

var command = new Command();
command.name = "name";
command.lastname = "lastname";
_command = command;

the binding does not update.

Is there a method or some way that instead of assigning a new instance to the object "_command" it replaces it's properties? something like

_command.clone(command);

Thanks!

My Zend Framework 2 Application has a view whereby I display a log of events, in a simple table format. I use several basic View Helpers to manipulate the presentation of the data in the table, but on these existing View Helpers all of the logic is contained to the View Helper itself, e.g:

namespace Application\View\Helper;
use Zend\View\Helper\AbstractHelper;

class GetSystemName extends AbstractHelper
{
    public function __invoke($val)
    {
        if ($val == 0){
            return 'Something';
        }
        if ($val == 1){
            return 'Something else';
       }
    }
}

My requirement is to build a function GetUserName to accept user_id and perform a check on the database to display the User's name, as the ID is of no value to the person using the system.

The way I see it I can either:

A) Start a new query from within the View Helper to return what I need or B) Use a function called getUser() from within the 'User' Module / UserTable class.

The code for B is:

namespace User\Model;

use Zend\Db\TableGateway\TableGateway;

 class UserTable
 {
 protected $tableGateway;

 public function __construct(TableGateway $tableGateway)
 {
     $this->tableGateway = $tableGateway;
 }

 //..other functions

 public function getUser($id)
 {
     $id  = (int) $id;
     $rowset = $this->tableGateway->select(array('id' => $id));
     $row = $rowset->current();
     if (!$row) {
         throw new \Exception("Could not find row $id");
     }
     return $row;
 }

What is the best option? And how would I implement it?

Apologies if this is a basic questions I am quite new to MVC and Zend.