i display 4 buttons for each elements in a list.

i want to know which button has data inside so i create an ActionResult and this returns true if contains data.

public ActionResult TieneNotificacion(string Pnombre, string Pcorreo1, string Pprefijo)
var lista = agp.CC15_EscalaMandoPorUsuario(Pnombre,Pcorreo1,Pprefijo);
if(lista != null){
 return Json(true);
return Json(false);

in the view i want to set the button class "btn btn-xs" if the method return false and "btn btn-xs btn-info" if return true.

$(document).ready(function () {
    function tieneNotificacion(Nombre,Correo1,Prefijo){

            type: "POST",

            url: "/CentralSoluciones/TieneNotificacion",

            data: { Pnombre: Nombre, 
                Pcorreo1: Correo1,
                Pprefijo: Prefijo },

            success: function (data) {

                if (data) {
                    return "btn btn-xs btn-info"
                else {
                    return "btn btn-xs"



and the html tag is like that:

<a href="@Url.Action("Detalles", new { Pnombre= item.Nombre, Pcorreo1=item.Correo1, Pprefijo=list.Prefijo })"

I'm developing ASP.NET MVC5 web app. I've seen a lot of stuff about generating pdf from html. However, I didn't find solution of my problem.

I have a html Razor view with elements. User is able to dynamically modify these elements i.e. add a column to a table by clicking on a button.

What I want to do is to generate a pdf document from the CURRENT html view.

I tried to use tools such as Rotativa. Unfortunately it generates pdf based on the static html (which is initally loaded when we refresh the page).

I've also tried the tool called NReco PDF Generator. It has method which generates pdf based on the passed html string. However, I don't know how to pass actual html content to controller and I'm not sure if all css styles would behave properly.

Thanks in advance

var openWos = @Model.MyMaintenanceDashboard.OpenWorkOrders;

Why is Visual Studio saying this is a syntax error? It runs fine, but what would the proper syntax be?

When this button is pressed

<input type="submit" value="Create" class="btn btn-default" />

I would like this html code to be created in the view

<a href='@Url.Action("index", "PatientReadings")'>
        <img src='@Url.Content("~/Images/AWT-Bed.png")'/>

I am trying to call an action from the controller using onclick method. For some reason it's not returning action I want, it's always jumping to public ActionResult Index() by default.

    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="Register" class="btn btn-default" onclick="location.href='@Url.Action("RegisterIndex", "Register")'"/>


I have created view automatically with a model. It's validating input for me by using already generated javascripts. If I change input tag to button it's not gonna do the required validation.

I'm working in a solution in ASP.NET

I have my login .cshtml page with that code:

if (WebSecurity.Login(email, password, rememberMe)) {
            string token = Convert.ToBase64String(Guid.NewGuid().ToByteArray());
        var db = Database.Open("BBDD");
        // Insertar token
        db.Execute("INSERT INTO token (token,date) VALUES ("+token+","+DateTime.Now+"");
         localStorage.setItem("var.token", token);

    } else {

I want to set a token in the localstorage.

How Can I do it?

Thanks in advance.

I have a class:

 public class Customer :IComparable<Customer>
            public int Id { get; set; }
            public string Name { get; set; }
            public int Salary { get; set; }

I also have a List:

Customer cust = new Customer() { Id=10,Name="Jack",Salary= 15000};
            Customer cust1 = new Customer() { Id = 10, Name = "Abby", Salary = 5000 };
            Customer cust2 = new Customer() { Id = 10, Name = "Zed", Salary = 152000 };

            List<Customer> CustomerList = new List<Customer>();

I understand why list.Sort wont work on Customer since Customer class has three properties and it does not know how to sort it. But if I implement the interface IComparable in Customer class I am able to sort the Customer List any way i want.

public class Customer :IComparable<Customer>
            public int Id { get; set; }
            public string Name { get; set; }
            public int Salary { get; set; }

            public int CompareTo(Customer other)
                return this.Salary.CompareTo(other.Salary);

Now my question is.. How does implementing CompareTo method let me sort CustomerList? I am not even overriding Sort Method or anything. I am confused since I have not used CompareTo method at all.

I read http://stackoverflow.com/a/4188041/2064292 but it does not answer my question.

I'm working on a website project and I have this problem in its "Contact Us" page!

I made a form to enable site visitors to be heard and the message will be delivered to different addresses depending on what they chose in the dropdown list regarding the subject of this message. but i can't seem to move forward in this project because an error keeps showing every time I run the page

the error is Compiler Error Message: CS1002: ; expected

and it shows this

Line 28:         }
Line 29:     }
Line 30:     protected void Button1_Click(object sender, EventArgs e)
Line 31:    
Line 32:             SmtpClient client = new SmtpClient();

can someone please help me with this? :'(

I have created a dynamic box plot chart which can produce more than 1 chart every time when the codes is executed. Each box plot chart has different Y axis value range.

Does anyone know how I could get the Y-value range of the chart?

For e.g. I want to get the Y axis value of 1 to 120 from Chart 1 and Y axis value of 1 to 35 from Chart 2 as shown below:

enter image description here

enter image description here Question: How to get Y axis value range displayed on a Box Plot Chart?

Thanks for any help.

I have code, that is not my and I need repair this code. I repair most of code. Can someone help me with this? Because Visual studio says it is only about expression. But I did not find problem.

<script type="text/javascript">
   $(function() { 
    setTimeout(function() { 
    var strip = new PhotoStrip('<%= photoStripR.ClientID  %>',        <%=this.ColumnCount %>,'#<%= photoStripR.ClientID  %>_left','#<%= photoStripR.ClientID  %>_right'
<%-- Seznam obrazku fancybox ma zobrazit v detailu --%>
  <asp:Repeater ID="Repeater1" runat="server" DataSourceID="ItemsSqlDataSource">      <ItemTemplate>'<%# ResolveUrl(Eval("Guid","~/App_Handlers/GetPhotoItemImage.ashx?Guid={0}")) %>',       </ItemTemplate>

I want to freeze the column header, so that i set UseStaticHeaders=True.

But i found that the Group Header had alignment problem (please see attached screen capture).

I had tried to use css, but not work.

enter image description here


i created a simple web service in asp .net that does some operations:

public int Area(int l, int b)
return l * b;

public int Perimeter(int l, int b)
return 2 * (l +b);

and i called it in HTML file, like:

<title>WebService Call using HTTP POST</title>
<form action="http://localhost:56472/WebSite2/Service.asmx/Area" method="POST">
<input name="l">
<input name="b">
<input type="submit" value="Click for Area">
<form action="http://localhost:56472/WebSite2/Service.asmx/Perimeter" method="POST">
<input name="l">
<input name="b">
<input type="submit" value="Click for Perimeter">

put this when i click for the result it will be returned as XML:

 <?xml version="1.0" encoding="UTF-8"?>
 <int xmlns="http://tempuri.org/">30</int> 

and what i want is i want the result in HTML not XML, how to do this?

can someone help please?

Thank You :)!

I'm trying to format this HTML so it looks like this: http://iforce.co.nz/i/tryvopws.4xy.png

I can't seem to get it right though! I can make the top part work but then the other sides resize to be really small. I want it to look like the picture.

Any help is appreciated!

<table cellspacing="0" border="0" width="100%">
      <tr class="s4-die">
       <td class="ms-pagebreadcrumb">
        <td valign="top" width="100%">
               <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="WebPartZone1" Title="loc:Top" />
         <table width="100%" cellpadding="0" cellspacing="0" style="padding: 5px 10px 10px 10px;">
           <td valign="top" width="60%">
               <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Left" Title="loc:Left" />
           <td valign="top" width="40%">
               <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Right" Title="loc:Right" />
          <td valign="top" width="60%">
               <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Left2" Title="loc:Left" />
           <td valign="top" width="40%">
               <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Right2" Title="loc:Right" />

Good day everyone, I would like to ask you on how to control submitting form if there is no file in fileupload. My code for uploading file is this.

FileInfo fi = new FileInfo(FileUpload1.FileName);
byte[] documentContent = FileUpload1.FileBytes;

string name = fi.Name;
string extn = fi.Extension;

da.InsertCommand.Parameters.Add("@DocumentName", SqlDbType.VarChar).Value = name;
da.InsertCommand.Parameters.Add("@DocumentContent", SqlDbType.VarBinary).Value = documentContent;
da.InsertCommand.Parameters.Add("@DocumentExt", SqlDbType.VarChar).Value = extn;


If there is no file selected and the submit button is clicked, I want something that will restrict this to be stored on the database. I don't know what to put in the if-else statement. Please help me.

I have created table in Oracle 11g,


connect with System.Data.OleDb, the connectionStrings is:

    <add name="DBConnStr" connectionString="Provider=msdaora;Data Source=test;User Id=test;Password=test;" />

and try to insert data into table TABLE1:

private void testInsert()
    string sql = "";
    int recordsAffected = 0;

    using (OleDbConnection openCon = new OleDbConnection(constr))
        sql = @"insert into table1 (column1, column2) values (:aaa, :bbb)";
        using (OleDbCommand command = new OleDbCommand(sql))
            command.Connection = openCon;

            command.Parameters.AddWithValue(":aaa", "test");
            command.Parameters.AddWithValue(":bbb", "0123456");

            recordsAffected = command.ExecuteNonQuery(); // <-- error here

but get ORA-01008 error at command.ExecuteNonQuery () line. Why is Oracle claiming that not all variables are bound?

If I replace the colon (:) prefix with @, I got ORA-00936 error. And if I remove all prefix, I got ORA-00984 error. What is the correct way to insert data into Oracle table?

Thanks in advance.

I'm having problems with a custom validator I created, in which I test whether data the user inputed is an integer, then I check if it's within a certain range. Currently, no matter what I enter, it just seems to say its not a number, and I don't know why it's causing this. I was wondering if any of you could spot my error.

My code to create all the controls is:

<asp:TextBox ID="txtGuess" runat="server" CausesValidation="True"></asp:TextBox>
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" TabIndex="1" Text="Submit" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtGuess" Display="Dynamic" ErrorMessage="Sorry, but this field cannot be blank"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="typeRangeValidator" runat="server" ErrorMessage="DefaultMessage" OnServerValidate="typeRangeValidator_ServerValidate"></asp:CustomValidator>

and the validation function is as follows:

 protected void typeRangeValidator_ServerValidate(object source, ServerValidateEventArgs args)
        int parsedValue;
        if (!int.TryParse(args.Value, out parsedValue))
            typeRangeValidator.ErrorMessage = "Sorry, but you must provide a number";
            args.IsValid = false;
            int minNum = (int)(Session["minNum"]);
            int maxNum = (int)(Session["maxNum"]);

            if(parsedValue < minNum || parsedValue > maxNum)
                typeRangeValidator.ErrorMessage = "Sorry, but your guess is out of bounds";
                args.IsValid = false;
                typeRangeValidator.ErrorMessage = "Valid!";
                args.IsValid = true;



Both minNum and maxNum are generated from a different page that I transfered from previously. Again, any help would be appreciated. Thanks!

I've been working on a project for a client and had a lot of fun integrating SignalR into the system.

Everything seems to work really well and the client is really excited about how the SignalR gives true real-time feedback for their application.

For the most part everything has gone swimmingly, however I've come into a strange issue I simply cannot pin down.

Everything works great for the following locales:

  1. en-US
  2. en-GB
  3. it
  4. nl

However these languages simply never get a callback from the hub:

  1. fr
  2. de
  3. es
  4. en-ZW - we use English Zimbabwe to check all the strings are translated.

I can step through the code right up until Clients.Client(ConnectionId).update(Result); (where ConnectionId is the correct Connection ID, and Result is the object ready to be serialized, with the first four languages this goes flawlessly and I get my Javascript method with the expected output.

On the last four languages however, the method is fired, but nothing comes through to the other side. Nothing. Zip.

If I replace the Strings.fr.resx file with the default Strings.resx then my site functions as expected, but since the Strings.en-ZW.resx file is identical to Strings.resx (only each string is wrapped in [()]) I doubt that is the issue. I also tried using the fr locale with all unicode translations (`, é, â, etc) removed, but that didn't help.

I've been going over this for almost a full day now and found nothing that would indicate the issue, and the fact that en works fine and en-ZW does not really confuses me.

Anyone have any suggestions?

Hub method:

public class ClientHub : Hub

    protected void UpdateRecords(List<Int32> ChangedValues) 
        using (var database = new DbContext())
            foreach (Record R in database.Records.Where(Rc => ChangedValues.Contains(Rc.Id))
                SignalRFormattedRecord Serialized = new SignalRFormattedRecord(Record);

                foreach (SavedFilter Filter in SavedFilters.ByRecord(Record))
                    // Next line is always called.



$.connection.clientHub.updateRow = function(value) {
    // update code works in all languages except FR, DE, ES and en-ZW.


Within my web application I have registered Google as a single sign-on provider:

app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions {
    ClientId = "8765.......apps.googleusercontent.com",
    ClientSecret = "Secret"

My app doesn't allow users to sign-up/register (instead their accounts are created by an administrator, but they can later link their account up with Google).

In my "Sign in with Google" controller, I am trying to issue a Challenge() to redirect to Google. This might not be thecorrect approach:

string redirectUri = "http://localhost:55262/SSO/Google/ProcessToken"; // actually created in code, but shown as string for clarity
AuthenticationProperties properties = new AuthenticationProperties();
properties.RedirectUri = Server.UrlEncode(redirectUri);
Context.GetOwinContext().Authentication.Challenge(properties, "Google");

This correctly sends the user to Google, but Google then presents Error: redirect_uri_mismatch, saying that:

The redirect URI in the request: http://localhost:55262/signin-google did not match a registered redirect URI.

I've seen this error before when the return URI collection in the Google control panel does not contain the redirect_uri specified.

If I debug in VS2015, I can see the redirect_uri property being set correctly in the AuthenticationProperties, but it seems that OWIN/Katana is not passing it to Google. Instead, when I hit Google, the return_uri is the default one used by OWIN/Katana. The one I set is being ignored.

The Google request details seem to confirm this:

scope=openid profile email

What am I doing wrong here please? Should I not be using Challenge() to allow users to link up their local application account with Google?

The Situation

I have come across some very suspicious PUT and GET requests in my IIS server logs. After Googling the requesters address, I have found information linking the IP's to known hacking teams. After each PUT there is an immediate GET for the same resource that was attempted to be uploaded to my server.

Question 1: Would this be considered a remote code execution attack?

Additional Testing Completed By Me:

The IIS logs show that the response given for the PUT request was 412 'Invalid file type all files are not uploaded'

I have turned on Failed Request Tracing and attempted to upload text files using CURL and this is the same response I am provided with and was not able to upload a file.

Question 2: What can I do to help prevent these type of attacks from being successful?

I can turn on IIS request filtering, but I am concerned that if I deny PUT my IIS application may be negatively impacted for any future web services.

I am developing a web app in ASP.NET with c#.

The top page of the app is available to everyone, so we use Anonymous authentication. There is a resource at a lower level which must be protected by smartcard + PIN.

I have set up Accept Client Certificates in the IIS console for this directory and I get the usual OS PIN prompt when I access that resource. So far so good.

However, all subsequent access to that resource then succeeds and I am never prompted for the PIN again.

The question: How can I configure (in IIS or web.config or even in c#) the page so that it always prompts me for PIN?


i only have a folder open and visual studio, its loads all the files and throws this error, i thought there must have been a memory constraint and restarted the system but that did not help either. So i guess my question to keep it simple, is there a way to actually free up memory on visual studio??

enter image description here