Subscribe: Web Forms
http://forums.asp.net/rss.aspx?ForumID=18
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
add  data  int  model  null  public virtual  public  return view  runat server  runat  server  set  string  system  view 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Web Forms

All Forums



All Forums



Last Build Date: Tue, 27 Jun 2017 19:10:21 -0700

 



change dropdown selection based on radio buttonlist selection in angularjs

2017-06-26T23:41:07.003-07:00

Hello everyone, I have this jsfiddle:

http://jsfiddle.net/baa2G/140/

I disabled the dropdownlist and I would like to change the dropdown selection based on the radio button list below the dropdown. So if I select the radio button first option, the dropdown should select first option and so on. How could I do that?

One more thing, for some reason angular js add an empty option in my dropdownlist. Is there a way I could stop that? 

Thanks. 




Multi views inside update panel don't work on IIS

2017-06-27T16:20:14.773-07:00

                                                                                                                             CHOOSE A FILTER TO SEARCH                                                                                                                                                                                                                                                                                                              Agent No.                                                                                &nb[...]



Parameters in the controllers from the view or model

2017-06-28T02:00:12.087-07:00

I am confused where actually the data is coming to the controller. I.e the parameters which we pass in the  methods that are in the controllers.

For example.

 public ActionResult Create(Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
	
            return View(student);
        }

in the above code Student is the model and it is passing the student model as input parameter and passing it to the view.

take example of the of filling up the field of edit page with existing data.

public ActionResult Edit(string id = null)
        {
            Student student = db.Students.Find(id);
            if (student == null)
            {
                return HttpNotFound();
            }
            return View(student);
        }
	

now we have input parameter as string.  It is coming from the view. as with click it pass the id to edit function of the controller to pass the data to display to the edit page.

I am confused either the data can be passed to the controller parameters from model or from the view ?  Because in above case  in create controller method the model student is  passed as input parameter but in edit method the string parameter is passed from the view.




Redirect to action not displaying it's view content.

2017-06-23T08:29:05.803-07:00

Hello

 public ActionResult Proc(Guid? processusId, bool? isDuplicate,String proCode="" )
        {

....

...

          return View("Proc", model);

        }

  [HttpPost]
       
 public ActionResult DupliProce(string strProcessusIDs)
{

...

...

 return RedirectToAction("Proc", new { processusId = strProcIDs, isDuplicate = "true", proCode = sCode });

}

It is redirecting to Proc view with all parameter and Proc View works fine and redireting Proc.cshtml. Proc.cshtml loads but in browser still showing DupliProce.cshtml view and it's content only.

help needed.




About data base security

2017-06-27T19:43:24.9-07:00

We have been using asp.net 3 layers, we does not use entity framewrok, we use encript connection string with a DLL for the DAL, but now on MVC how is this issue manage, now we use entity framework for the DAL, We have 3 scenarios, development environment, testing and production.  We are worry about security.




checking current time between time intervals

2017-06-27T02:52:57.78-07:00

Hello

column - starttime , endtime

datatype - smalldatetime

start time - 01/01/1900 23:00:00  end time  - 01/01/1900 05:00:00

I need to check whether current time is in between start time & end time. 

how to write query for that ?

neethu




Inserting a record to Access database using .NET c# InsertParameters.Add

2017-06-27T09:09:38.36-07:00

Hello,

I am trying to insert the data entered on the webform (.NET c#) to the MS Access database.

I have created a simple AccessDataSource as shown below.



        


            
            
            
            

        

When inserting the record into the Access database table, I need to add 2 more field/column data, "AreaCode" and "ReceiveNewsletter" after the user press the submit button in the code behind page (C#).


I am trying to accomplish this by using the code below but it is not working, only the first 3 fields ( VisitorName, VisitorEmailAddress and FeedbackMessage) that I have specified in the code shown above get inserted into the database table.

string varAreaCode = "03";
string varReceiveNewsletter = "-1";


AccessDataSource1.InsertParameters.Add("AreaCode", TypeCode.String, varAreaCode.ToString());
//AreaCode field is a 'Text' data type field

AccessDataSource1.InsertParameters.Add("ReceiveNewsletter", TypeCode.String, varReceiveNewsletter.ToString());
//ReceiveNewsletter is a 'Yes/No' data type field 

Please show me how to change the InsertParameters.Add code correctly for inserting the data into the MS Access database table.





Encrypting JWT Token

2017-06-28T00:49:00.83-07:00

Hi All,

Can anybody help in getting me the code to encrypt the JWT Token in C Sharp? I could able to do the encoding but I want to encrypt payload and then generate JWT token.

I found the sample code in java but not in c sharp.

String token = Jwts.builder().setSubject("sgsdss")

                                .claim("dsfsd", "1234")

                                .setExpiration(new Date(System.currentTimeMillis() + tokenExpirationDuration))

                                .compressWith(CompressionCodecs.GZIP)

                                .signWith(SignatureAlgorithm.HS512, key)

                                .compact();

Here they are using GZIP to compress and then signwith. do we have similar functionality in c sharp?

Thanks.




Getting the overall hours between a StartDate and EndDate

2017-06-20T07:28:53.457-07:00

Hi, I'm currently stuck on the StartDate and EndDate in my controller.  Here's the code for my project: MODEL: public class Payroll { //Primary Key public virtual int PayrollID { get; set; } public virtual int CrewPayAttendanceID { get; set; } [Display(Name = "Date From")] [DataType(DataType.DateTime)] public virtual string DateFrom { get; set; } [Display(Name = "Date To")] [DataType(DataType.DateTime)] public virtual string DateTo { get; set; } public virtual decimal OverallHours { get; set; } //Get current Total Hours public virtual decimal GrossPay { get; set; } // GrossPay = OverallHours * CrewRate public virtual decimal NetPay { get; set; } // Net Pay = Gross Pay - Deductions [DataType(DataType.Date)] public virtual string PaidDate { get; set; } } public class CrewPayAttendance { //Primary Key [Key] public virtual int CrewPayAttendanceID { get; set; } [Display(Name = "Crew")] public virtual int CrewID { get; set; } [Display(Name = "Time In")] [DataType(DataType.DateTime)] public virtual string TimeIn { get; set; } [Display(Name = "Time Out")] [DataType(DataType.DateTime)] public virtual string TimeOut { get; set; } public virtual decimal TotalHours { get; set; } // Taken from Time in and Time out [Display(Name = "Rate")] public virtual decimal CrewRate { get; set; } public virtual Crew Crew { get; set; } }   CONTROLLER: using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Net; using System.Web; using System.IO; using System.Web.Mvc; using Alphera_Payroll.Models; namespace Alphera_Payroll.Controllers { public class PayrollCalculatorController : Controller { // GET: PayrollCalculator public ActionResult Index() { return View(); } public ActionResult DateTime(Payroll model, DateTime? from, DateTime? to) { ViewBag.from = from; ViewBag.to = to; return View(model); } [HttpPost] public ActionResult Compute(Payroll model, CrewPayAttendance model2) //Compute for hours { //INCOMPLETE //Must ADD between Date From & Date To constraint for Total Hours model.OverallHours = (model2.TotalHours + model2.TotalHours); //INCOMPLETE model.GrossPay = (model.OverallHours * model2.CrewRate); ApplicationDbContext db = new ApplicationDbContext(); db.Payrolls.Add(model); db.SaveChanges(); return View(model); } public ActionResult TaxDeduction(Tax model)//Compute tax deduction { model.TaxDeductionAmount = (model.TaxPercentage * model.Payroll.GrossPay); ApplicationDbContext db = new ApplicationDbContext(); db.Taxes.Add(model); db.SaveChanges(); return View(model); } /* public ActionResult TaxConstraints(Tax tax, Payroll pay) { if (pay.GrossPay => 9999) { tax.TaxPercentage = 0.5; } return View(model); } */ public ActionResult TotalPay(Payroll model, Tax tax) //Compute for the NetPay { model.NetPay = (model.GrossPay - tax.TaxDeductionAmount); ApplicationDbContext db = new ApplicationDbContext(); db.Payrolls.Add(model); db.SaveChanges(); return View(model); } } }   I'm currently trying to get the Overa[...]



How to add cost per hotel and flight in duration cost table

2017-06-28T00:05:51.11-07:00

Problem

How to get cost per hotel and flight then add it in duration cost table based on flight date automatically .

Details

suppose i write flight date

26/07/2017 alexia 8days 04/08/2017 


it must automatically get cost from hotel price table and price from flight

then add it in duration cost table

so that

what query i write to get cost per hotel and flight when write flight date then insert it to duration cost table my database

CREATE TABLE program(
     ProgramID int primary key not null, 
    ProgramName varchar(30)
     ) 
    GO
     insert into program values(1,'Alexia'),(2,'Amon'),(3,'Sfinx') 
    GO
    CREATE TABLE ProgramDuration(
    DurationNo int primary key not null,
    programID int not null,
    Duration varchar(30) null
    )
    insert into ProgramDurationvalues(1,1,'3 for Alexia'),(2,1,'5 for Alexia')
    GO
    CREATE TABLE DurationDetail(
     DurationNo int not null,
     [Days]  varchar(20) not null, 
    HotelID int null,
     FlightID int null

    )
     insert into DurationDetail values (2,'Day1',1,'amsterdam to luxor','airport to hotel'), (2,'Day2',1,null,'AbuSimple musuem'), 
    (2,'Day3',1,null), 
    (2,'Day4',1,null),
     (2,'Day5',1,'Luxor to amsterdam') 
    GO
    CREATE TABLE DurationCost(
    DurationNo int not null,
    [Date] date not null,
    Hote_cost numeric(18,0) null,
    Flight_cost numeric(18,0) null,
    Transfer_cost numeric(18,0) null
    )
    insert into DurationCostvalues(
    2,'2017-06-25',25,500,20),
    (2,'2017-06-26',25,null,55),
    (2,'2017-06-27',25,null,null),
    (2,'2017-06-28',25,null,null),
    (2,'2017-06-29',25,500,null)
    GO
    CREATE TABLE [dbo].[FlightData](
        [FlighID] [nvarchar](50) NOT NULL,
        [FlightNo] [nvarchar](50) NOT NULL,
        [FlightDate] [datetime] NULL,
        [FlightTypeID] [int] NULL,
        [AirLine] [nvarchar](50) NULL,
        [Arrival] [time](7) NULL,
        [Departure] [time](7) NULL,
        [Price] [money] NULL,
        [Active] [bit] NULL
    )
      insert into FlightData values (1,'ms300',1,'egyptairline','6','10',200,1)

    CREATE TABLE [dbo].[FlightRoute](
        [FlightTypeID] [int] NOT NULL,
        [FlightFrom] [nvarchar](max) NULL,
        [FlightTo] [nvarchar](max) NULL,
        [Active] [bit] NULL,
        [FlightRouteWay] [nvarchar](max) NULL,
    )
    insert into FlightRoute values (1,'amsterdam','cairo',1,amsterdam to cairo), (2,'cairo','amsterdam',1,cairo to amsterdam)
    CREATE TABLE [dbo].[Hotel](
        [ProductID] [int] NOT NULL,
        [ProductName] [nvarchar](50) NULL,

     )
     insert into Hotel values (1,'Hilton'), (2,'Movenpick')

    CREATE TABLE [dbo].[HotelPrice](
        [ProductPriceID] [int] NOT NULL,
        [ProductID] [int] NULL,
        [FromDate] [datetime] NULL,
        [ToDate] [datetime] NULL,
        [HotelPrice] [numeric](18, 0) NULL,
    )
insert into HotelPrice values (1,1,01/07/2017,01-09-2017,20$), (2,1,02-09-2017,02-11-2017,30) 

 




Pass Html Table Multiple Rows to Controller

2017-06-25T14:26:20.83-07:00

Hello 

I need to create a form with several controls such as textbox and DateTime then by entering data and press add button, I need to add several records , the data will be added to l Html table, at the end, if I press submit, It will pass the data to the database (Controller).  I need to perform CRUD on HTML table before passing its values to the controller. 

I tried with 

http://www.c-sharpcorner.com/article/pass-dynamically-added-html-table-records-list-to-controller/ 

but it is not working 

I have seen that in waveapps.com as an example. 

any IDEA? 

Thanks 

ks 




Populate data from SQL Serve in grid like table

2017-06-27T23:51:25.23-07:00

I have a table with 54 columns; the first column is ID, the second column is short description and the rest of the 52 columns are bit type of data. How do I fill this grid based on the bit value in the database?
[...]



Screen flickers when click on a gridview page number

2017-06-26T17:15:12.13-07:00

Why does my screen flicker when click on a gridview page number? What do I need to do to stop doing it?




Cascading Dropdownlist & ViewModel

2017-06-27T18:46:46.523-07:00

Hello, I have the following models: Department (as city), District and Store. Department has one to many Districts Districts has one to many Stores I'm constructing a view where I create a new Store and the user can choose the Department(city) and then the District dropdownlist updates instantly with the corresponding districts. For this I created this ViewModel: StoreIndexData public class StoreIndexData { public Store Stores { get; set; } public Department Departments { get; set; } } This is the Controller where I populate the dropdownlist for the Department: public IActionResult Create() { //Departaments List List Departmentlist = _context.Departments.ToList(); Departmentlist.Insert(0, new Department { DepartmentID = 0, DepartmentName = "Select" }); ViewBag.DepartmentList = new SelectList(Departmentlist, "DepartmentID", "DepartmentName"); return View(); } And this is the View: @model Application.Models.ApplicationviewModels.StoreIndexData

Store


@Html.DropDownListFor(model => model.Stores.DistrictID, new SelectList(" "), "Select", new { @class = "form-control"})
And in the end of the view, this is my JS section: @section Scripts { This section calls this action: public JsonResult GetDistrictList(int DepartmentID) { List DistrictList = _context.Districts.Where(x => x.DepartmentID == DepartmentID).ToList(); return Json(DistrictList); } And that's it. When I run the application, well, the District dropdownlist don't populate  _Questions: Is it possible that I can't access this properties inside the JScript  "#DepartmentID"  like this since I'm using a viewmodel? Maybe I need to change it to something like "#Departments.DepartmentID"? Could this work using a ViewModel? I'm not adding the Department property inside the Store model because it would be irrelevant since it gets its Department thru the District. I saw in the example that I followed that they added this line ProxyCreationEnabled = false Inside the JsonResult action. I didn't add it because I don't know what it does and don't know the consecuences in my application if I add it. Thanks in advance for any help. Regards[...]



How do I find the index of the a row in an object of arrays

2017-06-27T22:49:42.46-07:00

Hello everyone, I have this model in angular js

$scope.model = {
                    blocks: [
                        {
                            block_id: 0,
                            title: "My block 1",
                            rows: [
                              {
                               row_id: 1,
                               name: "my name"
                               },
                              {
                               row_id: 2,
                               name: "my name 2"
                               },
                               {
                               row_id: 3,
                               name: "my name 3"
                               }
                            ]
                        },
                        {
                            block_id: 1,
                            title: "My block 2",
                            rows: [
                              {
                               row_id: 4,
                               name: "my name 4"
                               },
                              {
                               row_id: 5,
                               name: "my name 5"
                               },
                               {
                               row_id: 6,
                               name: "my name 6"
                               }
                            ]
                        }
                    ],
                    selectedBlock: undefined,
                    selectedRow: undefined,

}

$scope.updateRowSelected = function (row) {
                    //var rowIndex = ??
                    //var blockIndex=??
                    //$scope.model.selectedBlock = ??
                    $scope.model.selectedRow = row;
                   
                }

I have the selected row. How could I use that selected row to trace back to the current block it belongs to? And how could I find the index of the selectedRow and index of the block that the rows belong to?

Thanks.




Read large binary file into byte array - File.ReadAllBytes throws 'System.OutOfMemoryException'

2017-06-27T22:40:58.9-07:00

Running on Windows Server 2003, IIS 6.0, Visual Studio 2010, .Net Framework 3.5

The web service is throwing a "System.OutOfMemoryException" whenever it tries to read a file large binary file (> 80 Meg).

To make troubleshooting this issue easier, I have separated out the code into a simple web service with only one call
GetByteArrayFromFile which reads a file and returns a byte array.

It consistently throws the 'Out of Memory' exception with files larger than 80 Meg.

Are there any steps I can take to resolve this issue?

'**********************************************************
'Web Service Call
Imports System.Web.Services, System.Web.Services.Protocols, System.ComponentModel

  Namespace:="http://Testing.org/")> _
  _
  _
Public Class ProcSvcs   Inherits System.Web.Services.WebService

_  
Public Function GetByteArrayFromFile(ByVal PathFName As String) As Byte()    
Try      
  Dim Content() As Byte = System.IO.File.ReadAllBytes(path:=PathFName)      
  Return Content    
Catch ex As Exception      
   Throw New Exception(ex.Message)    
End Try  
End Function

End Class

 




System.StackOverFlowException

2017-06-27T22:37:32.067-07:00

Hi Folks,

I am dealing with a MVC application and I am stuck with a System.StackOverFlowException.

I have done some research about this error and found that it usually happens with recursive functions calls.

But I think this is a different  one.

I got the error when this query runs.

Select pes.* from pes where pes.pesid in 
(SELECT pesemp.pesid FROM pesemp 
Left JOIN emp ON pesemp.empid = emp.empid 
Left JOIN pesempfco ON pesempfco.pesempid = pesemp.pesempid 
Left JOIN fco ON pesempfco.fcoid = fco.fcoid 
Left Join pesemptrb on pesemptrb.pesempid = pesemp.pesempid 
Left Join loctrb on pesemptrb.loctrbid = loctrb.loctrbid 
Where pesemp.fim is null and fco.fcoid <> 9 ) 
Order by pes.gra 

The table generate by the query has 113 records but when I limit the number of records to 111 it runs without errors. 

Select pes.* from pes where pes.pesid in 
(SELECT pesemp.pesid 
FROM pesemp 
Left JOIN emp ON pesemp.empid = emp.empid 
Left JOIN pesempfco ON pesempfco.pesempid = pesemp.pesempid 
Left JOIN fco ON pesempfco.fcoid = fco.fcoid 
Left Join pesemptrb on pesemptrb.pesempid = pesemp.pesempid 
Left Join loctrb on pesemptrb.loctrbid = loctrb.loctrbid 
Where pesemp.fim is null and fco.fcoid <> 9 ) 
Order by pes.gra 
Limit 111 

Any ideas?




file is already opened exclusively by another user, or you need permission to view its data.

2017-06-27T19:54:09.75-07:00

 It is already opened exclusively by another user, or you need permission to view its data.

private void CreateDBFFile()
{
    string connection = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;

    using (OleDbConnection dbconnection = new OleDbConnection(connection))
    using (OleDbCommand command = dbconnection.CreateCommand())
    {
        dbconnection.Open();

        command.CommandText = "CREATE TABLE Test (Id Integer, Changed Double, Name Text)";
        command.ExecuteNonQuery();
    }
}

My web.config file has connection string


  

I am trying to create a dbf file on my K drive. I keep getting an error on my dbConnection.Open() statement saying:

The Microsoft Jet database engine cannot open the file 'k:\temp1'. It is already opened exclusively by another user, or you need permission to view its data.

K:\ is not a mapped drive. I gave network service userName to temp1 folder by going under security tab. I also gave modify rights to the Network service. Still keep getting this error. I also tried to put the entire above code in console application, that didn't work either. I keep getting the same error.

Any help will be greatly appreciated.




Send Selected Data from Gridview into Email

2017-06-26T21:33:57.957-07:00

Dears, I'm trying to Send Selected Data from Gridview into Email but not working fine  <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Affiliate Link Application in ASP.NET Core

2017-06-27T22:05:39.957-07:00

Hi, how can I track user SignUp via Affiliate Links on my ASP .NET Core Application? Is it possible to, say, "pre-populate" some Form Field with Friend's Code, when an anonymous user click the link, in order to ensure the Bonus for whom indicates their friend to my site)? Any tutorial on how to implement this kind of Feature? Thanks!


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 4 44 45 46 47 48 49 50 51 52
1 Abandon Rigs