mardi 5 mai 2015

Timeout Error in Stored Procedure in C#

i have this stored procedure to retreave data from database (dynamic query). and i am calling this stored procedure from c# codebehind, i am passsing two parameters from c# to this stored procedure.

alter procedure [dbo].[GetCompleteCPTDetails]
    @Practice_Short_Name varchar(50),
    @Uploaded_Date nvarchar(max)
as
begin
DECLARE @CPTtablename nvarchar(300)
DECLARE @vQuery NVARCHAR(max)
DECLARE @upldate nvarchar(100)
set @upldate = @Uploaded_Date
set @CPTtablename ='ACER_CLAIMS_MASTER_DETAIL_Hist_'+@Practice_Short_Name
SET @vQuery = 'select Practice_Short_Name,Service_Date_From,Carrier_Name,
   Location_Description,Patient_Number,Patient_First_Name,
   Patient_Last_Name,Voucher_Number,Procedure_Code,Service_Fees,
   Service_Payments,Service_Adjustments,Acer_Status,Acer_Allowed_Amount
   from ' +@CPTtablename+' 
   where Uploaded_Date =''' + @upldate + ''' 
   order by acer_status asc, Service_Date_From desc, Patient_First_Name asc'
EXEC (@vQuery)

end
GO

but when i am running this query it is giving me TimeOut error. but if i assign value to my parameters in SP and Run SP from query windows then it is showing correct data.

can any please explain me why it is giving timeout error if i am calling it from C# codebehind.

drawing graphs/diagrams

I search for library/control/something that automatically draws a diagram/graph. I found an interesting library for WPF(GraphX) but it doesn't work on web forms application. I don't need a library complicated like that but something simple that draw me a graph from given parameters. Of course I could draw it y myself using Graphics but it is very hard to get the look I want(and it takes a lot of code and time).

Graph in my project is simple mathematics graph(vertices and edges), but not a chart. Example: enter image description here

Tell me if there is any control/library to make it possible. It can generate image which be next put on the site.

Website doesn't start with default page

I have a compiled website that works perfectly on my IIS 7 box. When I pass the same exact website to a customer, and bring up the site in IIS, the site starts with the registration.aspx instead of default.aspx. I checked setting and everything seems right but can not figure this out.

Thanks for the input

VS2015 using the Nightlies

I have VS2015RC. I was looking to plug it into the nightly nuget feed. If i configure the normal way i don't get the intellisense from the nighly feed in project.json

i.e Nuget Package manager Settings Nuget Package manager Settings

Also in the "Nuget Package Manager for Solution" if I change the package source to nightlies, nothing is listed, and it doesn't seem possible to check the "include prerelease" checkbox.

Are there any docs to show how to use the Nightlies with ASP.Net5 ?

insufficient system storage.The server response was: Too many emails per connection

im sending mail to one admin address and one mail sending to that person who entered details saying "thanks for contacting us." in second mail/receipent mail sending its getting error."insufficient system storage.The server response was: Too many emails per connection" in second method "SendConfirmationMail" its giving error. too many mails

  private void SendMail()
        {
            System.IO.StringWriter sw = new System.IO.StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            System.IO.StreamReader r = null;
            r = new System.IO.StreamReader(Server.MapPath("~/ContactMail.txt"));
            string body = r.ReadToEnd();
            MailMessage mail = new MailMessage();
            mail.To.Add(new MailAddress("srinivas@gmail.com"));
            mail.Body = body;
            mail.IsBodyHtml = true;
            //replacing txt file with dynamic content
            body = body.Replace("<%Name%>", Name);
            body = body.Replace("<%email%>", email);
            body = body.Replace("<%message%>", message);
            mail.Subject = "Applying For job";
            mail.Body = body;
            mail.IsBodyHtml = true;
            SmtpClient MailServer = new SmtpClient();
            MailServer.Send(mail);
            ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "clentscript", "alert('Thank u for contacting us..');", true);

        }
        private void SendConfirmationMail()
        {
            System.IO.StringWriter sw = new System.IO.StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            MailMessage mail = new MailMessage();
            mail.To.Add(new MailAddress(email));
            mail.Body = "Thank u for contacting us...";
            mail.IsBodyHtml = true;
            mail.Subject = "Thank you Mail";
            mail.IsBodyHtml = true;
            SmtpClient MailServer = new SmtpClient();
            MailServer.Send(mail);
            ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "clentscript", "alert('Thank u for contacting us..');", true);
    }

Unable to display image

When i try to execute my application all the data's in the database r getting displayed and instead of storing image i stored its path in DB and displaying the image but when i render it in chrome i says

Error: 404 not found

But when i check it physically the images are present in folder where i uploaded.

Screenshot:

screenshot of my output

EmpdetController.cs

[HttpPost]
    public ActionResult UploadFile()
    {
        var file = Request.Files[0];
        var path = Path.Combine(Server.MapPath("~/Photos"), file.FileName);
        file.SaveAs(path);

        // prepare a relative path to be stored in the database and used to display later on.
        var filename = path;
        // save to db
        return Json(filename.ToString(), JsonRequestBehavior.AllowGet);

    }

EmpdetList:

<h2>EmpdetList</h2>

<table class="table table-bordered table-hover table-striped" ng- table="tableParams" show-filter="true">
<tr ng-repeat="Empdet in EmpdetList">                       
    <td data-title="'Id'" filter="{ 'Id': 'text' }" sortable="'Id'">{{Empdet.Id}}</td>
    <td data-title="'FirstName'" sortable="'FirstName'" filter="{ 'FirstName': 'text' }">{{Empdet.FirstName}}</td>
    <td data-title="'LastName'" sortable="'LastName'" filter="{ 'LastName': 'text' }" >{{Empdet.LastName}}</td>
    <td data-title="'Email'" sortable="'Email'" filter="{ 'Email': 'text' }">{{Empdet.Email}}</td>
    <td data-title="'PhotoText'" sortable="'PhotoText'" filter="{ 'PhotoText': 'text' }"><img ng-src={{Empdet.PhotoText}} class="img-responsive"/></td>
    <td data-title="'Age'" sortable="'Age'" filter="{ 'Age': 'text' }">{{Empdet.Age}}</td>

    <td data-title="'Action'">
        <div data-toggle="modal" data-id="{{Empdet.Id}}" data-index="{{$index}}" data-name="{{Empdet.Id}}" ng-click="DeleteEmployee(Empdet.Id)"  title='Click to delete the Account' class="open-confirm-delete fa fa-trash-o deleterow" style="height: 24px!important;">
        </div>
    </td>
</tr>
</table>

How to fill the gridview control in ASP.Net using XML data?

I want to fill the gridview control using xml data. Please help me out. XML data has attributes too.

Using of goto statement logic is not a good idea in .Net tech ..? [on hold]

I used goto statement to access a logic in my project. but my TL told this is not good sound of writing code, you have to change your logic in that project.

so i asked you experts give a suggestion which one is correct.

and my code is

For Each gvrow As GridViewRow In GrdView.Rows
                chk = DirectCast(gvrow.FindControl("chk_Artid"), CheckBox)
                lblArtId = DirectCast(gvrow.FindControl("lblArtId"), LinkButton)
                txtRemarks = DirectCast(gvrow.FindControl("txtRemarks"), TextBox)
                lblIss = DirectCast(gvrow.FindControl("lblIss"), Label)
                txtNumofFigures = DirectCast(gvrow.FindControl("txtNumofFigures"), TextBox)
                lblstage = DirectCast(gvrow.FindControl("lblstage"), Label)
                lblArtStageTypeID = DirectCast(gvrow.FindControl("hdnArtStageTypeID"), HiddenField)
                grph_Val = Is_graph_Update(lblstage.Text)
                If ViewState("chk_updt") = 1 Then    '''' IssueLevel Update
                    If chk.Checked = True Then
                        chk_Set = True
                        If txtNumofFigures.Text <> "" Then
                            If txtRemarks.Text <> "" Then

                                strQuery = "select Instruction from " & Init_Tables.gTblSplInstructions & " where AutoArtID='" & lblArtId.Text & "' and Iss='" & lblIss.Text & "' "
                                dt = RecordManager.GetRecord_Multiple_All(strQuery, "Temptable")
                                If dt.Rows.Count > 0 Then
                                    strQuery = "Update " & Init_Tables.gTblSplInstructions & " Set Instruction='" & txtRemarks.Text & "',EmpAutoID='" & SessionHandler.sUsrID & "' where AutoArtID='" & lblArtId.Text & "' and Iss='" & lblIss.Text & "' "
                                Else
                                    strQuery = "Insert into " & Init_Tables.gTblSplInstructions & " (AutoArtID,Iss,Stage,Instruction,DeptCode,InstDate,EmpAutoID) values('" & lblArtId.Text & "','" & lblIss.Text & "','" & lblstage.Text & "', '" & txtRemarks.Text & "', '|90|', '" & Format(Date.Now, "dd-MMM-yy") & " " & Date.Now.ToLongTimeString & "','" & SessionHandler.sUsrID & "')"
                                End If

                                StrUpdateQuery = "Update " & Init_Tables.gTblIssueInfo & " set Remarks='1' ,CorrFigs='" & txtNumofFigures.Text & "',Grapstatus=NULL,GraphArtStageTypeID=NULL where JBM_AutoID='" & lblArtId.Text & "' and RevFinStage like '%" & lblstage.Text & "%' and iss='" & lblIss.Text & "'"

                                RecordManager.UpdateRecord(strQuery)
                                RecordManager.UpdateRecord(StrUpdateQuery)
                                RecordManager.DeleteRecord("delete from " & Init_Tables.gTblJBM_Allocation & " where autoartid='" & lblArtId.Text & "' and Stage='" & lblstage.Text & "' and DeptCode=90 and status='0' and iss='" & lblIss.Text & "'")
                            Else
                                lblStatus.Text = "Enter any remarks."
                                Return
                            End If
                        Else
                            lblStatus.Text = "Enter the No.of figs."
                            Return
                        End If
                        GoTo Next_stage
                    End If


  End If
            Next

    Next_stage:

            For Each li As ListItem In chkArticle.Items   '' bala 30-mar-2015
                ChapterID = li.Text
                'qry = "select  * from  " & Init_Tables.gTblChapterInfo & " where JBM_AutoID='" & ViewState("lblArtId").ToString() & "'  and ChapterID='" & ChapterID & "'"
                qry = "select  * from  " & Init_Tables.gTblChapterInfo & " where JBM_AutoID='" & lblArtId.Text & "'  and ChapterID='" & ChapterID & "'"
                dt = RecordManager.GetRecord_Multiple_All(qry, "Temptable")

                If dt.Rows.Count > 0 Then
                    Autoart_ID = dt.Rows(0)("AutoArtID")
                End If

                If li.Selected = True Then
                    chk_Set_chapter = True

                    qry = " select * from JBM_ProdTempStatus where  AutoArtID ='" & Autoart_ID & "'"
                    dt.Rows.Clear()
                    dt = RecordManager.GetRecord_Multiple_All(qry, "JBM_ProdTempStatus")

                    If dt.Rows.Count > 0 Then
                        ''Update

                        qry = "Update JBM_ProdTempStatus set EmpAutoID='" & SessionHandler.sUsrID & "' ,  ProcessedDate='" & Format(DateTime.Now, "dd-MMM-yy hh:mm:ss") & "',Grapstatus=NULL  where  AutoArtID ='" & Autoart_ID & "'"
                        RecordManager.UpdateRecord(qry)
                    Else
                        ''Insert

                        qry = "insert into JBM_ProdTempStatus(EmpAutoID,AutoArtID,EmpArtStage,gProcess,nFigs,ProcessedDate,Jbm_AutoID,iss,Stage,ArtStageTypeID) values('" & SessionHandler.sUsrID & "' ,'" & Autoart_ID & "','" & Init_Barcode.gstrGraphics & "','GS03' ,'" & txtNumofFigures.Text & "','" & Format(DateTime.Now, "dd-MMM-yy hh:mm:ss") & "','" & lblArtId.Text & "'," & IIf(lblIss.Text = "", "NULL", "'" & lblIss.Text & "'") & ",'" & lblstage.Text.Trim() & "','" & lblArtStageTypeID.Value & "') "
                        RecordManager.UpdateRecord(qry)
                    End If


                    '  RecordManager.UpdateRecord(strQuery)
                ElseIf li.Selected = False Then
                    '' Delete

                    qry = "Delete from JBM_ProdTempStatus where  AutoArtID ='" & Autoart_ID & "' and JBM_AutoID='" & lblArtId.Text & "' "

                    RecordManager.UpdateRecord(qry)
                End If
            Next

Dataset data not showing .00 decimals

I have a table data like as shown below.

EmpID   Salary
123     350.00
124     450.000

I am taking same into dataset using dataadapter. When i observe data in dataset salary is showing as 350 and 450 without decimals i.e .00.

I want to consider .00 also in dataset. Please help.

how to add data into list view from datatable

I have one confusion with SQL Query.

I have three tables, student, books, book_taken_by_student. In the last table we have all the details about books taken by students.

In list view I bind the student name as row vies and different books name as column vies from student and books table. The list view look like

| Book1 | Book2 | Book 3 | Book 4|

A |

B |

C |

D |

E |

F |


Now with help of book_taken_by_student table I want to bind Yes or No in front of student name related with book name taken by them

How I can solve this question.

Finally I want to show my list view like this

| Book1 | Book2 | Book 3 | Book 4|

A | Yes | No | Yes | Yes

B | No | Yes | Yes | No

C | No | Yes | Yes | No

D | Yes | No | Yes | Yes

E | Yes | No | Yes | Yes

F | No | Yes | Yes | Yes


JS event delegation not working for some components [on hold]

Here is my fiddle showing my code so far : http://ift.tt/1GN0Cvf

Problem Description :

I am using event-delegation here, where on the click of a div I take the clicked div into an object and give user an option to give title to that div and then append that text to the div OR remove the component completely.

Now the problem is, I have two shapes here : Square and Circle. Now the event fires properly for Circle - the text appends successfully . Now when I click on the square and save the title for it , the text is appended to the circle only.

Why is the event not delegated or why is the text not getting appended to the square component ?

NOTE: I am saving the style of the whole event plan via $.POST and entering the attributes to the DB.

Prevent circumventing ASP.NET minification

I've got some ASP.NET that I'm deploying as an Azure cloud service. The javascript files have comments in them that I'd like not to be visible to anyone consuming the JS. I'm taking advantage of ASP.NET bundling and minification:

http://ift.tt/1tHBXlU

This seems to be a nice solution in that it removes all comments during the minifcation process. But I can't count on the fact that the user won't directly point his or her browser directly to the individual, original js files. I'm trying to figorue out how to prevent the user from pulling the js files directly (forcing them to pull only a bundle), in order to prevent viewing comments. Is there a way to implement a black list of files that can't be downloaded? If not, I was thinking of adding a series of random characters to the name of each js file. Lastly, if that doesn't seem like a good idea, I would investigate injecting something into the VS build process to strip comments on publish.

Any thoughts would be welcome.

How can I verify a certificate password using C# in asp.net?

I have a .cer, a .key and a password and I have to verify them before saving them into the database.

Openssl-net just will return "Invalid version of libeay32, expecting 1.0.0a Development, got: 1.0.2b Release".

Is there another way?

Need a help for my quiz application using asp.net

I am developing quiz application in that i am creating dynamic check box for answer in that i need store a checked value in the cache when user clicks the refresh then also need to show old data what he is clicked so please give me a idea Thanks

MVC: Can I post to a controller without using javascript/ajax/jquery?

The problem is I want to change server side variables using a dropdownlist in a partial view. You can't use scripts in partial views.

Is an html helper I can use to post a simple variable to a controller (like an int) when the user clicks an item in the dropdownlist (or bootstrap dropdown)?

how to call the master page method in content page but which is not inheritted from the master page

How to call master page method in content page but the content page is not inheritted from the master page. what i have to do to call the master page method in content page

Override IE Local Intranet Settings

The website that I am developing is added to the list of local intranet sites in IE browsers.

enter image description here

Then in compatibility view settings the check box for the "display intranet sites in Compatibility View" is checked.

enter image description here

Problem, the site that I am developing right now is displayed as compatibility view in IE browsers (For very obvious reason).

What I tried so far is adding the below header but to no avail.

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

and

<httpProtocol>
  <customHeaders>
    <clear />
    <add name="X-UA-Compatible" value="IE=edge" />
  </customHeaders>
</httpProtocol>

Removing the said settings is not an option since there are 300,000 computers to modify around the world (Lucky for me).

Question, Is there a way we can override this settings?

How to add label with cross sign of selected dropdownlist detail

When i add keyword I want look like this, please anybody will help me how do i do it. If i select the data from the dropdownlist is will show with some background blue color and selected item in label with X sign, when this X sign selected it will be deselected. and those labels i want to add to database.thanks in advance.

Radiobutton Selected value not pass to the controller

I have 2 radio buttons with mvc view.When i do form submit that Checkboxes values not pass to the controller.

I have a form submit like this,

@using(Html.BeginForm("Index","Employee",FormMethod.Get))
{
    <b>Search by :</b>@Html.RadioButton("Searchby", "EmpName",true)<text>Name</text>
    @Html.RadioButton("Searchby", "IsPermanant")<text>Id</text><br />
    @Html.TextBox("Search");
   <input type="submit" value="Search" />
}

I have a controller

public ActionResult Index(string Search, bool Searchby)//In here searchby is null
{

}

How to call a function that is in the code behind of jquery dialog

I try to show jquery dialog by clicking the Delete button ( which also serves to erase data if the user than in the dialog ), but when I press the Delete dialog then disappears after the second and screen pops . I'd love someone to help me because I really green in jquery And how to check user code approved in dialog Thank you :)

    <script type="text/javascript">
            $(function () {
                $("#dialog-confirm").hide();
                $("#but_Delete").click(function () {
                    $("#dialog-confirm").dialog({
                        resizable: false,
                        height: 250,
                        width: 500,
                        modal: true,
                        buttons: {
                            "delete": function () {
                                $.ajax({
                                    type: "GET",
                                    contenttype: "application/json; charset=utf-8",
                                    data: "{null}",
                                    url: "http://ift.tt/1dMetLe",
                                    dataType: "json",
                                    success: function but_Delete_Click(res) {
                                       
                                    },
                              
                                });
                                $(this).dialog("close");
                            },
                            "Cancel": function () {
                                $(this).dialog("close");
                            }
                        }


                    });

                    //$(".selector").dialog({Zz
                    //    closeOnEscape: false

                    //});
                });

            });

  </script> 
protected void but_Delete_Click()
{          
     if (TextBox_campeny.Text != null || TextBox_Addres.Text != null || TextBox_tel.Text != null)
     {                 
           con.Open();
           string id = tb.Tables[0].Rows[i]["id"].ToString();
           SqlCommand cmd = new SqlCommand("Delete from tbl_Customer where Id='" + id + "'", con);
           cmd.ExecuteNonQuery();                 
           Response.Write("blabla!");
           con.Close();
           con.Open();
           SqlCommand cmd_u = new SqlCommand("Delete from tbl_Users where IdCustomer='" + id + "'", con);
           SqlDataAdapter dac = new SqlDataAdapter(cmd_u);
           dac.Fill(tb);
           if (butuc == 1)
           {
                 Response.Redirect("LoginPage.aspx");
           }
           else
           {
                 if(tb.Tables[0].Rows.Count != 1)
                 {
                     if (i == 0)
                     {                                
                           bind();
                     }
                     else
                     {
                           if (tb.Tables[0].Rows.Count - 1 == i)
                           {
                                  i--;
                                  bind();
                           }
                           else
                           {
                                  bind();                                  
                           }
                      }
                      else
                      {
                           Empty_Textbox();
                           but_Delete.EnableTheming = false;
                      }

                  }
             }
             con.Close();
       }
}

repeater not showing data in proper format in asp.net and C#

hie i am using nasted repeater to show data from two tables. in first repeater it gets a data from a table called category. and shows in first repeater child repeater gets value from another repeater using where condition. here is code.

<form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:Repeater ID="parecntrptr" runat="server" onitemdatabound="Repeater1_ItemDataBound">
            <HeaderTemplate>
            </HeaderTemplate>
            <ItemTemplate>
                <div class="panel menu-style" id="section-1">
                    <div class="panel-heading">
                        <h4 class="panel-title" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true">
                            <asp:Label ID="menuheadlbl" runat="server" Text='<%#Eval("cat_name") %>'></asp:Label>
                        </h4>
                    </div>
                    <asp:Repeater ID="childrptr" runat="server">
                        <HeaderTemplate>
                            <div id="collapseOne" class="panel-collapse collapse in">
                        </HeaderTemplate>
                        <ItemTemplate>

                                <div class="media dish-pad">
                                    <div class="media-left">
                                        <a href="#">
                                            <img class="media-object" src='<%#Eval("item_img_loc") %>' alt='<%#Eval("iterm_name") %>'>
                                        </a>
                                    </div>
                                    <div class="media-body">
                                        <h4 class="media-heading">
                                            <asp:Label ID="Label2" runat="server" Text='<%#Eval("iterm_name") %>'></asp:Label>
                                        </h4>
                                        <p>
                                            <asp:Label ID="Label3" runat="server" Text='<%#Eval("item_description") %>'></asp:Label>
                                        </p>
                                    </div>
                                    <div class="media-right media-right-wid">
                                        <label>
                                            <i class="fa fa-dot-circle-o"></i>Veg
                                        </label>
                                        <label>
                                            <i class="fa fa-dot-circle-o"></i>Veg
                                        </label>
                                        <div class="input-group">
                                            <asp:TextBox ID="TextBox1" runat="server" disabled="" CssClass="form-control" Text='<%#Eval("item_price_full") %>'></asp:TextBox>
                                            <div class="input-group-addon">Rs</div>
                                        </div>
                                    </div>
                                </div>
                        </ItemTemplate>
                        <FooterTemplate>
                            </div>
                       </div>
            </FooterTemplate>
            </asp:Repeater>
            </ItemTemplate>
            <FooterTemplate>
            </FooterTemplate>
        </asp:Repeater>
    </div>
</form>

c# code.

 SqlCommand cmd;
    SqlDataAdapter da;
    DataSet ds;
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyCon"].ConnectionString);

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["rest_id"] != null)
        {
            if (!IsPostBack)
            {
                RepeterData();
            }
        }
        else
        {
            Response.Redirect("Login.aspx");
        }
    }


    private void RepeterData()
    {
        con.Open();
        cmd = new SqlCommand("Select * from add_category WHERE rest_id='admin'", con);
        DataSet ds = new DataSet();
        da = new SqlDataAdapter(cmd);
        da.Fill(ds);
        parecntrptr.DataSource = ds;
        parecntrptr.DataBind();

    }
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Repeater Repeater2 = (Repeater)(e.Item.FindControl("childrptr"));

            foreach (RepeaterItem repeated in parecntrptr.Items)
            {
                Label menuhead = (Label)FindControlRecursive(repeated, "menuheadlbl");
                Label1.Text = menuhead.Text;
            }
            string catname = Label1.Text;
            cmd = new SqlCommand("Select * from menu_items WHERE rest_id='admin' AND cat_name='"+catname+"';", con);
            DataSet ds = new DataSet();
            da = new SqlDataAdapter(cmd);
            da.Fill(ds);
            Repeater2.DataSource = ds;
            Repeater2.DataBind();
        }

    }

    public static Control FindControlRecursive(Control root, string id)
    {
        if (root.ID == id)
            return root;

        return root.Controls.Cast<Control>().Select(c => FindControlRecursive(c, id)).FirstOrDefault(c => c != null);
    }

Error message for data duplication in asp.net

I have tried this below code but it show unique key constraint error but i want it as a pop-up message see my below code.please help me out from these problem

using (SqlConnection con2 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
        {
            var fromdate = DateTime.Parse(txtfromdate.Text);
            var todate = DateTime.Parse(txttodate.Text);
            var datedif1 = (todate - fromdate).Days;

            var sqlInsert = new SqlCommand("INSERT INTO datelist ([datedif],[batch],[daywk],[semester],[weekbatch],[subject],[facultyname],[facultyid],[WeekMonth])  VALUES  (@datedif,@batch,@daywk,@semester,@weekbatch,@subject,@facultyname,@facultyid,@weekMonth)", con2);
            var sqlParamater = sqlInsert.Parameters.Add("@datedif", SqlDbType.Date);
            var sqlParameter1 = sqlInsert.Parameters.Add("@batch", SqlDbType.NVarChar);
            var sqlParameter2 = sqlInsert.Parameters.Add("@daywk", SqlDbType.NVarChar);
            var sqlParameter3 = sqlInsert.Parameters.Add("@semester", SqlDbType.NVarChar);
            var sqlParameter4 = sqlInsert.Parameters.Add("@weekbatch", SqlDbType.NVarChar);
            var sqlParameter5 = sqlInsert.Parameters.Add("@subject", SqlDbType.NVarChar);
            var sqlParameter6 = sqlInsert.Parameters.Add("@facultyname", SqlDbType.NVarChar);
            var sqlParameter7 = sqlInsert.Parameters.Add("@facultyid", SqlDbType.NVarChar);
            var sqlParameter8 = sqlInsert.Parameters.Add("@WeekMonth", SqlDbType.NVarChar);

            con2.Open();
            try { 
            for (var i = 0; i <= datedif1; i++)
            {
                var consecutiveDate = fromdate.AddDays(i);

                sqlParamater.Value = consecutiveDate;
                sqlParameter1.Value = batch1;
                sqlParameter2.Value = dayweek;
                sqlParameter3.Value = semester;
                sqlParameter4.Value = weekbatch;
                sqlParameter5.Value = subject;
                sqlParameter6.Value = faculty;
                sqlParameter7.Value = facultyid;
                sqlParameter8.Value = weekmonth;

                int s= sqlInsert.ExecuteNonQuery();
               }
            con2.Close();
                }
            catch(ConstraintException ex)
            {
                throw new ApplicationException("data are duplicated");
            }
        }
    }

And these is my screen shot of error which am getting.look at these enter image description here

How can I reuse facebook's DotNetOpenAuth accesstoken?

I have successfully authenticated by using C# DotNetOpenAuth according to this tutorial Easy OAuth Login with ASP.NET.

But I have one question. Everytime I access to the web site, it will display a facebook login page then user must click a login button to continue. The question is how can I reuse the first accesstoken to avoid the login page?

Is it possible? Which code statement should I use?

Thank you very much!

Can't send parameters through POST on asp.net vNext app. (beta 3) (MV6, mono, EF7, OSX)

I hope someone can help me with this... I'm working on osx on a new small project and "getting to know" the new vNext with MV6 and Entity Framework 7, with mono, kestrel, and using sublime text for the coding... I have a very simple form:

<div class="login-form-outer">
    @using (Html.BeginForm("Login2", "Account", null, FormMethod.Post, new { @class = "form-horizontal", role = "form", @autocomplete="off" }))
    {
        @Html.AntiForgeryToken()
        <h4>Use a Local Account to log in.</h4>
        <hr>
        @Html.ValidationSummary(true)
        <div class="form-group">
            @Html.LabelFor(m => m.Name, new { @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.TextBoxFor(m => m.Name, new { @class = "form-control" })
                @Html.ValidationMessageFor(m => m.Name)
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Log in" class="btn btn-default" />
            </div>
        </div>
    } </div>
</div>

The form submits, the action "Login2" gets called, but the parameter never reaches the action... This is the action BTW.

[HttpPost]
[AllowAnonymous]
public IActionResult Login2([FromBody] string Name)
{   
    Console.WriteLine(Name);
    Console.WriteLine("Login2");
    return RedirectToAction("Index", "Home");
}

The only thing the console shows is "Login2", and the redirection also works.

The thing is... I have a virtual machine running a SQL Server database... I installed visual studio 2015 there, and executed the exact same project (shared folder) using WEB, KESTREL, and IIS, and they all worked! The parameter gets printed in the console... So I don't really know where the problem is... is it mono? is it kestrel on OSX?... please help!

I usually work with Rails and Laravel, I'm a noob here...

Thanks in advance.

Jquery Tag it in asp.net

I am using jQuery UI widget Tag it. Code which i am using is working fine but all the Tag values visible on the browser.

Code I am using is below

    <script src="http://ift.tt/183v7Lz" type="text/javascript" charset="utf-8"></script>
    <script src="http://ift.tt/X4OQpz" type="text/javascript" charset="utf-8"></script>
      <script src="../JavaScript/tag-it.js"></script>
    <link href="../CSS/tagit.ui-zendesk.css" rel="stylesheet" />
    <link href="../CSS/jquery.tagit.css" rel="stylesheet" />
    <script>
        $(function(){
           var sampleTags = [<%# this.SuggestionList %>];
            //var sampleTags = ['c++', 'java', 'php', 'coldfusion', 'javascript', 'asp', 'ruby', 'python', 'c', 'scala', 'groovy', 'haskell', 'perl', 'erlang', 'apl', 'cobol', 'go', 'lua'];
            $('#myTags').tagit();         
            $('#singleFieldTags').tagit({
                availableTags: sampleTags,            
                allowSpaces: true,
                singleFieldNode: $('#mySingleField')
            });
           });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div id="content">
            <p>              
                <input name="tags" id="mySingleField" value="Apple, Orange" disabled="true">
            </p>
            <ul id="singleFieldTags"></ul>
    </div> 
    </form>
</body>

Code behind

string queryString = "select * from SIB_KWD_Library ORDER BY Keyword asc";

    using (SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["vConnString"].ToString()))
    {

        using (SqlCommand command = new SqlCommand(queryString, connection))
        {

            connection.Open();

            using (SqlDataReader reader = command.ExecuteReader())
            {

                while (reader.Read())
                {

                    if (string.IsNullOrEmpty(SuggestionList))
                    {
                        SuggestionList += "\'" + reader["Keyword"].ToString() + "\'";
                    }
                    else
                    {
                        SuggestionList += ", \'" + reader["Keyword"].ToString() + "\'";
                    }

                }
            }
        }
    }

In browser source code all the tag keywords are visible. Something like

var sampleTags = ['c++', 'java', 'php', 'coldfusion', 'javascript', 'asp', 'ruby', 'python', 'c', 'scala', 'groovy', 'haskell', 'perl', 'erlang', 'apl', 'cobol', 'go', 'lua'];

Please suggest any other way to do this.

Thanks in advance :)

How to get the appropriate (usercontrol) div id when button client click?

I created a user control with flipping functionality mouse over(front & back). ChartPin Button will be used to stop the flipping card and back will be displayed by using JavaScript.

My question whenever I click ChartPin (first user control) always second user control is flipping is stopped not the first one. Why? Also i saw that view frame source, it seems usercontrolid_divid is added correctly.

FrameSource: (Similarly second control HtmlChartWithFlipper2_Card1 ... )
function ChartPin(ctrl) {
var content = document.getElementById("HtmlChartWithFlipper1_Card1");
var CardFront = document.getElementById("HtmlChartWithFlipper1_Card1Front");
var CardBack = document.getElementById("HtmlChartWithFlipper1_Card1Back");
PinUnPin(content, CardFront, CardBack, ctrl);
}

I appreciate your help. Thanks

ScreenShot: enter image description here

Please find the sample code:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="HtmlChartWithFlipper.ascx.cs" Inherits="TApplication.UserControl.HtmlChartWithFlipper" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<link href="../Pixel-Admin/assets/stylesheets/Flipper.css" rel="stylesheet" />

<script type="text/javascript">
    function fillsvg() {
        alert('fillsvg()');
    }

    function ChartPin(ctrl) {
        var content = document.getElementById("<%= Card1.ClientID %>");
        var CardFront = document.getElementById("<%= Card1Front.ClientID %>");
        var CardBack = document.getElementById("<%= Card1Back.ClientID %>");

        PinUnPin(content, CardFront, CardBack, ctrl);

    }

    function PinUnPin(Content, CardFront, CardBack, ctrl) {
        if (Content.className == 'flipper') {
            ctrl.title = "UnPin";
            ctrl.src = ctrl.src.replace("pin.png", "pin-outline.png");
            Content.classList.remove('flipper');
            CardFront.classList.remove('front');
            CardFront.classList.add('back');
            CardBack.classList.remove('back');
            CardBack.classList.add('front');
        }
        else {
            ctrl.title = "Pin";
            ctrl.src = ctrl.src.replace("pin-outline.png", "pin.png");
            Content.classList.add('flipper');
            CardFront.classList.remove('back');
            CardFront.classList.add('front');
            CardBack.classList.remove('front');
            CardBack.classList.add('back');
        }

    }
</script>

<div>
    <table id="HCWF_tbl" runat="server" width="100%" border="1">
        <tr>
            <td>
                <div class="flip-container" ontouchstart="this.classList.toggle('hover');">
                    <div id="Card1" class="flipper" runat="server">
                        <div id="Card1Front" class="front" runat="server">
                            <span class="name">Front
                            </span>
                        </div>
                        <div id="Card1Back" class="back" runat="server">
                            Back
                            <table id="HCWF_BackTbl" runat="server" width="100%">
                                <tr>
                                    <td>
                                        <asp:ImageButton ID="btnExport" runat="server" ImageUrl="~/Images/Login/download.png" Width="18px" Height="18px"
                                            ToolTip="Export" AlternateText="Export" OnClientClick="fillsvg()"
                                            OnClick="btnExport_Click" />
                                    </td>
                                    <td align="right">
                                        <asp:ImageButton ID="ChartPin" runat="server" ImageUrl="~/Images/Login/pin.png" Width="17px" Height="17px"
                                            ToolTip="Pin" AlternateText="Pin"
                                            OnClientClick="ChartPin(this); return false;" />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>


            </td>
        </tr>
    </table>
</div>

Browser Remember password set username to other textboxes also

When I use browser remembered password, after login, some textboxes in my forms shows username. I am confused, how it works? Please provide solution to avoid this problem?

MySql: Variable 'sql_select_limit' can't be set to the value of '-1'

Hi Guys, I have implemented MySqlSessionStateProvider in asp.net and it works like a charm on my Local PC i.e. Windows 7 but when the application is deployed on Windows Server 2003 on IIS 6.0 it results in the below Exception:

(MySqlException (0x80004005): Variable 'sql_select_limit' can't be set to the value of '-1']
 MySql.Data.MySqlClient.MySqlStream.OpenPacket() +236
 MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows,  Int64& lastInsertId) +60
 MySql.Data.MySqlClient.MySqlDataReader.GetResultSet() +50
 MySql.Data.MySqlClient.MySqlDataReader.NextResult() +733
 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) +942
 MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() +43
 MySql.Data.MySqlClient.MySqlCommand.Close() +67
 MySql.Data.MySqlClient.MySqlDataReader.Close() +77

Can you please advice for the solution as soon as possible. Thanks in advance

long delays in AcquireRequestState

Using performance monitoring tool "New Relic" I am seeing occasional (but too many) long delays in the "AcquireRequestState". I am talking about 10, 20 second delays, sometimes minutes.

I know we have not written our own event handlers for this event.

Where do I even begin looking for the cause of these delays? The little information I have found so far on msdn has not been helpful.

Module load warning on dotnetnuke

I get a warning saying Module load warning I log in with a different user roles. enter image description here

I dont get this when I login as the superuser. Also I have checked the event viewer and found no errors regarding the module.

Route and pass multiple keys with multiple values in urls

I currently give the opportunity to my website's users to select a list of products based on one value in one category. I use the RouteCollection class for the url to look better.

ex: value 'red' in category 'colour' which gives 'http://ift.tt/1QkLAUj'

I would like to offer the opportunity to make searches with more parameters with check boxes to ...check.

ex: 'red' in colour and '33cl' for the volume which gives 'http://ift.tt/1zzfyQa'

I think I can handle that quite easily and find a solution by myself. My issue comes with the fact that I would like to keep my routing policy with more than one value by key.

ex: 'red' and 'white' in 'colour' and '33cl', '75cl', '2l' in 'volume'. The expected result should look like this: 'http://ift.tt/1QkLD2o' or 'http://ift.tt/1zzfyQe'

Can you tell me how to form the url while clicking on the search button after having checked the desired values and how to handle the url in order to make some requests on the database?

How can I properly overload a WebAPI 2 Controller with multiple collection parameters?

I'm trying to design my WebAPI controller with overloaded Get methods that will be selected based on the parameters a user provides. I'm able to get this to work properly in some cases, but when I have multiple collection parameters on a method my controller is no longer able to select the correct route, even if I am not specifying both collections.

For example the following set up works:

[RoutePrefix("data/stock")]
public class StockDataController 
    : ApiController {

    private readonly IDataProvider<StockDataItem> _dataProvider;

    public StockDataController() {
        _dataProvider = new StockDataProvider();
    }

    [Route("")]
    public IEnumerable<StockDataItem> Get([FromUri] string[] symbols) {
        // Return current stock data for the provided symbols
    }

    [Route("")]
    public IEnumerable<StockDataItem> Get([FromUri] string[] symbols, DateTime time) {
        // Return stock data at a specific time for the provided symbols
    }

}

Selects Method 1

GET http://server/data/stock/?symbols[]=GOOG&symbols[]=MSFT

Selects Method 2

GET http://server/data/stock/?symbols[]=GOOG&symbols[]=MSFT&time=2015-01-01

Once I add the following overload, then everything breaks down:

    [Route("")]
    public IEnumerable<dynamic> Get(
        [FromUri] string[] symbols, [FromUri] string[] fields) {
        // Return specified stock data fields for the specified symbols
    }

I would expect the following request to select Method 3:

GET http://server/data/stock/?symbols[]=GOOG&symbols[]=MSFT&fields[]=Price&fields[]=Volume

Instead I receive the error:

Multiple actions were found that match the request: Get on type StockDataController Get on type StockDataController

Is it possible to have multiple collection parameters in this way? If so, what am I doing wrong here?

How to account for Properties.Settings.Default in ASP.NET 5

I'm referencing a third-party DLL that reads configuration from Properties.Settings.Default.DefaultHostName. How do I configure this in my ASP.NET 5 application?

In previous versions of ASP.NET this would have appeared in the web.config as

<applicationSettings>
  <DllName.Properties.Settings>
    <setting name="DefaultHostName" serializeAs="String">
      <value>Sample</value>
    </setting>
  </DllName.Properties.Settings>
<applicationSettings>

Cannot connect to database getting error 26

I have been trying to do the MVCMusic Store Project. I have created a project and connected to one database fine. I have the database for the mvc music store project in my server explorer and can open it. However, whenever I try to create a user it tells me it cannot connect. Error is below.

Server Error in '/' Application. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Source Error:

Line 80: // Attempt to register the user Line 81: MembershipCreateStatus createStatus; Line 82: Membership.CreateUser(model.UserName, model.Password, model.Email, "question", "answer", true, null, out createStatus); Line 83: Line 84: if (createStatus == MembershipCreateStatus.Success)

Source File: c:\projects\Bricks\Bricks\Controllers\AccountController.cs Line: 82

Stack Trace:

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) +5340655 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +244 System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +5350915 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +145 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +922 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +307 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) +518 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +5353725 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +38 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +732 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +85 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1057 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +196 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) +146 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) +16 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry) +94 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry) +110 System.Data.SqlClient.SqlConnection.Open() +96 System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +88 System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +239 System.Web.Security.SqlMembershipProvider.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status) +2456 System.Web.Security.Membership.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status) +207 Bricks.Controllers.AccountController.Register(RegisterModel model) in c:\projects\Bricks\Bricks\Controllers\AccountController.cs:82 lambda_method(Closure , ControllerBase , Object[] ) +104 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +156 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +27 System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22 System.Web.Mvc.Async.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) +29 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32 System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +50 System.Web.Mvc.Async.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() +225 System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34 System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100 System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27 System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +36 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +28 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +36 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9690172 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

Confirm email doesn't work in asp.net mvc

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Web;
 using System.ComponentModel.DataAnnotations;
 using WebValidation.Common;
 using System.Web.Mvc;

 namespace WebValidation.Models
{
    [MetadataType(typeof(EmployeeMetaData))]
    public partial class Employee
    {
    [System.Web.Mvc.Compare("Email")]

    public string ConfirmEmail { get; set; }
    }

This is my code for confirming email address, but after I run my application, the confirm email always say that it doesn't match with email address. Although I have copy email and paste on confirm email, it still said not match!

Anyone tell me what's the problem?

How to create a Button with the same function of ScrollBar Button CSS/ASP.Net

I'm trying to create a button in ASP.NET which I want the Scrollbar buttons have the same functionality of the buttons which make the div go sideways

Like the following image

http://ift.tt/1ADfY3j

How can I do it?

Thank you guys

Process azure blobs and download them via ASP.NET

I am running a website on an Azure Web App (standard tier S1) where you can download files from a blob storage in different formats (xml, json).

I am inserting these files (html, text, images as base64 string) as block blobs into a container. Right now I am downloading all blobs and convert the result into a desired format, zip it and offer this as download on my ASP.NET website.

I see a problem here that the whole download and zip process runs inside the web app which could take a while and also reach the memory limit (1.75 GB on S1) when I am downloading, converting and zipping a lot of files. I am expecting more than 100.000 files per container with a resulting container size of 10 GB.

What would be the best way to offer a download of the whole container in a specific format (xml, json) which also has been zipped?

Possible solutions I have found that could help are:

  • Appending all blobs of the container to a "result blob" in the desired format. This would double the storage requirements of course http://ift.tt/1dLOQKn
  • Zipping files directly to the output stream http://ift.tt/1ADfY3g

Thanks

Blank page ejected while Print the report from RDLC in ASP.net

We are using RDLC report and when I print the report with Portrait it eject first page as blank, for landscape it working fine.

I am using Firefox as browser.

how to show new column value in aspx file without compilation [on hold]

I need a mechanism to fetch data from table and put it in aspx file without touching the cs file.I have an asp.net application where back end is SQL server. Label value is populated from SQL tables. Suppose I have added new column in one of the tables and need to show the new column value in aspx page, how it is possible to do without a compilation.

Means I don't want to change cs files, but I am okay to change aspx files

I don't understand why a class is "public"

I'm beginning to learn C# and I come from a C++ background. The example page I was supposed to create by these instructions looks like

using System.Web;
using System.Web.Mvc;

namespace MvcMovie.Controllers
{
    public class HelloWorldController : Controller
    {
        // 
        // GET: /HelloWorld/ 

        public string Index()
        {
            return "This is my <b>default</b> action...";
        }

        // 
        // GET: /HelloWorld/Welcome/ 

        public string Welcome()
        {
            return "This is the Welcome action method...";
        }
    }
}

My main question is why the HelloWorldController class is prefixed by public. I understand that HelloWorldController is derived from Controller, but why does a class need to be public in the first place? My understanding of the words public and private is that they only have meaning if they're functions inside a class, and that public are the ones that can be used by instances of that class. Also, where is my main.cs in this Visual Studio ASP.NET MVC project that I created?

Access Database Unchanged

I'm trying to add comments to a database. I'm starting with an Access database to be sure I have the code correct before going to the next step. The two files I'm using are Comments.aspx and the code file Comments.aspx.vb.

Here's what I have so far. The contents of Comments.aspx are:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Comments.aspx.vb" Inherits="Comments" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ift.tt/15udxSm    transitional.dtd">
<html xmlns="http://ift.tt/lH0Osb">
<head runat="server">
    <title>Leave Your Comments</title>
    <style type="text/css">
        .style2 { width: 250px; }
        .style3 { color: #793300; }
    </style>
</head>

<body>
    <form id="frmComments" runat="server">
    <div style="text-align: center">
        <h1 class="style3">Please leave your comments below.</h1>
 <table align="center">
        <tr><td class="style3"> 
            First Name : </td>
            <td class="style2"> 
                <asp:TextBox ID="txtFName" runat="server" Width="250px"></asp:TextBox></td> </tr>
        <tr> <td class="style3"> 
            Last Name : </td>
            <td class="style2"> 
            <asp:TextBox ID="txtLName" runat="server" Width="250px"></asp:TextBox></td></tr>
        <tr> <td class="style3"> 
            E-Mail : </td>
            <td class="style2">
            <asp:TextBox ID="txtEmail" runat="server" Width="250px"></asp:TextBox></td></tr>
        <tr> <td class="style3"> Comments :&nbsp; </td>
            <td class="style2"> 
            <asp:TextBox ID="txtComments" runat="server" TextMode = "MultiLine" Height="60px"   Width="250px"></asp:TextBox></td></tr> 
</table>
    <br /><asp:ImageButton ID="btnContactUs" runat="server" Height="50px"
                ImageUrl="~/Images/Dark_Continue.gif" />
    </div>
    </form>
</body>
</html>

The contents of Comments.aspx.vb are:

Imports System.Data.OleDb

Partial Class Comments
  Inherits System.Web.UI.Page
  Private Property FNameParam As Object
  Private Property LNameParam As Object
  Private Property CommentsParam As Object
  Private Property EMailParam As OleDbParameter

Sub ImageButtonRun_Click(ByVal sender As Object, ByVal e As EventArgs)
   Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=/Test.mdb"

   Dim dbConnection As New OleDbConnection(ConnectionStringSettings)
      dbConnection.Open()
   Dim commandString As String = "INSERT INTO Contacts(FName, LName, EMail, Comments) " & _
    "Values(@FName, @LName, @EMail, @Comments)"

   Dim dbCommand As New OleDbCommand(commandString, dbConnection)

   Dim FNameParam As New OleDbParameter("@FName", OleDbType.VarChar, 50)
      FNameParam.Value = txtFName.Text
      dbCommand.Parameters.Add(FNameParam)

   Dim LNameParam As New OleDbParameter("@LName", OleDbType.VarChar, 50)
      LNameParam.Value = txtLName.Text
      dbCommand.Parameters.Add(LNameParam)

   Dim EMailParam As New OleDbParameter("@EMail", OleDbType.VarChar, 255)
      EMailParam.Value = txtEmail.Text
      dbCommand.Parameters.Add(EMailParam)

   Dim CommentsParam As New OleDbParameter("@Comments", OleDbType.VarChar, 255)
      CommentsParam.Value = txtComments.Text
      dbCommand.Parameters.Add(CommentsParam)

  dbCommand.ExecuteNonQuery()
     dbConnection.Close()
End Sub

Private Function ConnectionStringSettings() As String
    Throw New NotImplementedException
End Function

End Class

Absolutely nothing at all happens after I fill in the form and click the image button. Most of what I've read points me in this direction' but it's obviously wrong. Please help.

How can I protect my asp.net web api? I can not understand the template well

I am new to ASP.NET MVC. Now all I know is how to add the authorize attribute to my controller or action.

How can I check if I have the access, and if not, how do I sign up and log in?

Duplicated data in MVC linq query

I have a question regarding linq query. My controller code looks like this:

public ActionResult Show_Trans(int id = 0)
    { 
        //this checks if the id exists in the database
        var check = db.Student_Trans.Where(s=>s.student_id == id).FirstOrDefault();
        // if not, show a javascript alert
        if(check == null){
            return Content("<script type='text/javascript'>alert('No transaction so far.');</script>");
        }

        // this return the data that equals to the id
        return PartialView(db.Payments_vw.Where(s=>s.student_id == id).ToList());

    }

In my database view (Payments_vw), for example, the student with student id of 2 has 3 transactions namely: Miscellaneous, Parents Share, Uniform.

The question is: when I tried to view it in my Views, it returns the exact number of rows but the datas are repeated or should I say, all are in Miscellaneous transaction but the Parents Share and Uniform are not shown. Why? Any help is greatly appreciated. Thanks.

How does family safety work

How does Family safety in windows 8 manage to have a count-down timer that shuts down the computer after a specific time without being able to force close via task-manager. Is this done thru a windows service or is there another method used?

Ironspeed: adding encoded hyperlink

When new record has been added to the database, my webpage built using ironspeed automatically sends email with the new content. What I'd like to add to the email is the hyperlink that would allow the recipient to go and edit that new record.

I've tried to follow this guide, but the problem is that hyperlinks are encoded, so i.e. instead of .../VBS_Business_details/Show-VBS-Business-details.aspx?VBS_Business_details=2 (where 2 is the Primary Key of the table that I'm working on) that I would get from the example from Ironspeed I need something like .../VBS_Business_details/Show-VBS-Business-details.aspx?VBS_Business_details=QVR9M%2bfIF [...]

asp.net MVC 2 view with slow UI responsiveness

my web application MVC view displays a grid of records, some of which the user can select and post their data back to the server. As long as the record count is in the order of multiples of dozens, the page is responsive. Problems occur when the records are in the order of a thousand and a half. I've experienced two kinds of problems, one in chrome, one in IE 11. First of all the query to retrieve the records from the DB is kind of slow, but acceptable, let's say that after 5=10 seconds the controller will call a "return view()" passing a model which is a collection of about 1500 records. Then this happens in Chrome: the browser renders the page quick enough considered the number of record, but after that the page becomes unresponsive in all its elements: as an example, consider the to activate a checkbox, it takes about 10 seconds before you see the check mark after you clicked. In IE11 this happens instead: the page hangs for about three minutes between the jquery method "document.ready" and its anonymous handler function. After that the page renders all its elements and its responsiveness is acceptable. My Application is developed in MVC2, and besides jquery, it uses datatables to display the grid, together with bootstrap for styling. Every record has about 20 fields so the page will have 20 form controls (input type=hidden) to post back for each selected record. Considering nothing of that matter happens when I'm retrieveing few records, can you help me understand what's going on and how I can give performance to my web page? Thanks in advance......

jquery when checkbox is not checked hide a textbox

i have a text box and a checkbox, when the checkbox is unchecked , i need to disabled the text box and when the user selects the checkbox, i want to re enable the textbox

i tried this:

asp.net code:/h3>

<div class="checkConfiguration">
                                <asp:CheckBox runat="server" ID="stopGeneralNumber" Text="General Number"   CssClass="cbStopReason" Checked="false" />
                                <asp:TextBox runat="server" Enabled="false"></asp:TextBox>
                            </div>

Jquery code
 $('.cbStopReason').on('click', function () {
        if ($(this).attr('checked')) {
            alert("now checked");
            $(this).nextAll("input").removeAttr("disabled");
        } else {
            alert("now un checked");
            $(this).nextAll("input").attr("disabled", "disabled"); 
        }
    })

the jquery code is already in document ready function, but the problem is that my code works good to disable the textbox, but it doesn't work to re enable it , what wrong did i do please?

Url rewrite in MVC

i work at a MVC application and i want to make url's more friendly. i was trying to do that using routes but at some url's it doesn't work.

i want a url like http ://localhost:55696/fr/Pages/Lists?pageType=PropertiesList&list=Market to become http: //localhost:55696/fr/(market_in_french)

I was trying with

routes.MapRoute(
    name: "MarketFr",
    url: UrlStrings.ResourceManager.GetString("Market", new CultureInfo(CultureEnum.fr.ToString())),
    defaults: new {controller = "Pages", action = "Lists"}
);

but the result is http://localhost:55696/fr/market?pageType=PropertiesList&list=Market

how can I solve this. The Lists method is defined like this:

public ActionResult Lists(string pageType, string list = "", string viewType = "")

I can't pass a raw body without receiving a null response

I've just finished following this tutorial: http://ift.tt/1ACZDLU

And I'm trying to accomplish the trivial task of sending an abstract/raw request body without the stupid/useless middle layer in ASP.NET trying to interpret the body contents as a pre-defined class I've already created.

Here's my super simple code ASP.NET seems to %$#& up:

[HttpPost]
[Route("test")]
public string test([FromBody] string json)
{
    return json;
}

Which would lead you to think that POSTing to this URI with the following body: "trouble shooting fun" OR "{"info":"troubleshooting fun"}"

would simply result in this response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 4

{"info":"troubleshooting fun"}

This is the kind of response you'd expect from all the other web frameworks like Django or Ruby-o-Rails because it just makes sense, but in ASP.NET Web API there is an additional layer working behind the scenes that forces you to create the request and response objects manually by declaring them as local classes like so:

public class hardCodedRequestJson
{
    public string keyValuePair { get; set; }
}

So... ummm this is kind of cool, if you want some useless backwards compatibility with XML but this approach comes at the cost of being stuck with extremely specific parameters for each API call, for my situation I'd have to make hundreds of different combinations of classes and functions that account for the dynamic number of possibilities the client must have when making an API call to the server.

How could I feed any kind of JSON object I wanted into an ASP.NET Web API controller and get that EXACT json I requested back as a response??

Storing data in cache vs in file storage in asp.net

We have a website which shows up, RSS feeds from multiple other websites owned by us, now we have 2 options to load RSS from live url:

  1. Using .Net caching object to serve the latest feeds every 2 hours.
  2. Using File based (Storing in xml form and reading using XmlDocument), pulling out latest feeds and saving it to file for 2hours and update the file after expiry, and displaying the content on the site from this file.

Can anyone suggest which would be the best method to implement.

My vote is for File based because with caching we are using the server resource for the next 2hours after which it will expire, but with file based we are reading the content from local file and showing it.