Quantcast
Channel: CodeProject Latest postings for ASP.NET
Viewing all 3938 articles
Browse latest View live

Still having some display problems

$
0
0
Greetings again,

This is part of the solution that the great Richard provided last week.

The app takes empID and determines if the employee has ever completed the form before.

If this is the first time the employee is compleing the form, then the form is completely blank so employee can complete entire form.

This works great.

It also checks to see if the employee had completed the form before, if yes but not the previous year, then employee name, title, email and employee ID are loaded but the rest of the form is blank so the user can complete the rest of the form.

This also works great.

Here is the part that we are still having problem with.

An employee can complete one gridview control, say GridView1, add an additional row and complete that row.

In this situation, if the employee completed form the previous year, then when the data that the employee had completed the previous year is loaded, it displays the two rows that employee completed for GridView1.

The problem is that all other gridview controls like grvspouse, grvspouse, etc for instance, are are also loaded with two rows even though those rows are blank.

Is there somethin I can change in the attached code that will ensure that those gridview controls like the two examples I showed above, show just one row since they have not been completed before?

Protected Sub txtEmpID_TextChanged(sender As Object, e As EventArgs) Handles txtEmpID.TextChanged
      If String.IsNullOrEmpty(txtEmpID.Text) Then
          checkusername.Visible = False
          Return
      End If

      ' Clear the controls:
      'txtEmpID.Text = String.Empty
      txteName.Text = String.Empty
      txttitle.Text = String.Empty
      txtemail.Text = String.Empty
      lblStatus.Text = String.Empty

      Gridview1.DataSource = Nothing
      Gridview1.DataBind()
      grvspouse.DataSource = Nothing
      grvspouse.DataBind()
      grvDiv.DataSource = Nothing
      grvDiv.DataBind()
      grvReim.DataSource = Nothing
      grvReim.DataBind()
      grvHon.DataSource = Nothing
      grvHon.DataBind()
      grvGift.DataSource = Nothing
      grvGift.DataBind()
      grvOrg.DataSource = Nothing
      grvOrg.DataBind()
      grvCred.DataSource = Nothing
      grvCred.DataBind()

      checkusername.Visible = True
      dprocessed.Visible = True
      lblStatus.ForeColor = System.Drawing.Color.Red

      Using Conn As New SqlConnection(ConfigurationManager.ConnectionStrings("constr").ConnectionString)
          Using cmd As New SqlCommand("ValidateEmpID", Conn)
              cmd.CommandType = CommandType.StoredProcedure
              cmd.Parameters.AddWithValue("@empID", txtEmpID.Text)

              Conn.Open()
              Using dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
                  If Not dr.Read() Then
                      imgstatus.ImageUrl = "images/Icon_Available.gif"
                      lblStatus.Text = "This must be the first time you are completing this form. Proceed to complete entire form. If you feel there is a mistake, please contact the office"
                      txteName.Enabled = True
                      txttitle.Enabled = True
                      txtemail.Enabled = True
                      txtEmpID.Enabled = True
                      GridPanels.Enabled = True
                      btnNext.Enabled = True
                      Return
                  End If

                  imgstatus.ImageUrl = "images/NotAvailable.jpg"
                  txteName.Text = dr("employeeName").ToString()
                  txttitle.Text = dr("empTitle").ToString()
                  txtemail.Text = dr("email").ToString()
                  txtEmpID.Text = dr("empID").ToString()

                  If dr("previousYear").ToString() = "1" Then
                      lblStatus.Text = "Please verify your information for accuracy. Then complete rest of the form."
                      txteName.Enabled = True
                      txttitle.Enabled = True
                      txtemail.Enabled = True
                      txtEmpID.Enabled = True
                      GridPanels.Enabled = True
                      btnNext.Enabled = True
                      fillSourceRecords()

                  ElseIf dr("thisYear").ToString() = "1" Then
                      lblStatus.Text = "You have already completed this form. Please close the form. If you feel there is a mistake, please contact the office"
                      txteName.Enabled = False
                      txttitle.Enabled = False
                      txtemail.Enabled = False
                      txtEmpID.Enabled = False
                      GridPanels.Enabled = False
                      btnNext.Enabled = False

                  Else
                      lblStatus.Text = "No entries this year, nor the previous year. Please complete the form. If you feel this is a mistake, please contact Clerk to the CEO and BOC at 404-371-3224"
                      txteName.Enabled = False
                      txttitle.Enabled = False
                      txtemail.Enabled = False
                      txtEmpID.Enabled = False
                      GridPanels.Enabled = False
                      btnNext.Enabled = False
                  End If
              End Using
          End Using
      End Using
  End Sub

  Private Sub fillSourceRecords()
      Dim conn_str As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString

      Using conn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("constr").ConnectionString)
          conn.Open()
          Using sourcecmd As SqlCommand = New SqlCommand()
              sourcecmd.CommandText = "uspGetAllRecs"
              sourcecmd.CommandType = CommandType.StoredProcedure
              sourcecmd.Parameters.AddWithValue("@empID", txtEmpID.Text.Trim())
              sourcecmd.Connection = conn
              Using ad As SqlDataAdapter = New SqlDataAdapter(sourcecmd)
                  Dim ds As DataSet = New DataSet()
                  ad.Fill(ds)
                  Gridview1.DataSource = ds
                  Gridview1.DataBind()
                  grvspouse.DataSource = ds
                  grvspouse.DataBind()
                  grvDiv.DataSource = ds
                  grvDiv.DataBind()
                  grvReim.DataSource = ds
                  grvReim.DataBind()
                  grvHon.DataSource = ds
                  grvHon.DataBind()
                  grvGift.DataSource = ds
                  grvGift.DataBind()
                  grvOrg.DataSource = ds
                  grvOrg.DataBind()
                  grvCred.DataSource = ds
                  grvCred.DataBind()
              End Using
          End Using
      End Using

  End Sub

ASP.NET MVC

$
0
0
I have been a web developer more than 10 years using ASP.NET Web Forms and I would like to brush-up my skills and currently looking at ASP.NET MVC. I was looking at a few courses on Udemy and Pluralsight and also at a few ebooks. Do you guys have any recommendations on which courses or books are great from start to end?

How to get a field's value from a linq query

$
0
0
Hi. I'm implementing asp.net core project. In my controller class I have a query like below that joins two tables.

          var UpdQuery = from a in _context.Applicant
                                       join p in  _context.PersonApplicant on a.ApplicantId
                                       equals p.ApplicantId
                                       where    applicant.applicantvm.ApplicantId == a.ApplicantId // && applicant.applicantvm.ApplicantType == a.ApplicantType
                                       select new { a, p };
I want to get the value of one of Updquery's fields which is called ApplicantType and it is of type int. For doing this, I wrote a query like below to get that value. However it doesn't give me a correct value.

                        var formerApplicantType = UpdQuery.Select(u => u.a.ApplicantType).SingleOrDefault();
                        Debug.WriteLine("formerApplicantType:" + int.Parse(formerApplicantType.ToString()));

I appreciate if any one tells me where do I make a mistake?

Binding combox in gridview with selected value of another comboBox

$
0
0
Hi all, I hope I got the right forum...

I can do what the subject states when the comboBox or DropDown is NOT in a gridview, as in the code below which populates the room DDL with the value that was selected in the building DDL

Protected Sub DDLbuilding_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDLbuilding.SelectedIndexChanged
        'Create DataTable
        Dim dtRooms As New DataTable() ' - Room Numbers
        dtRooms.Columns.Add("Room", Type.GetType("System.String"))

        'Get Buildings for this campus
        RoomTable = RoomAdapter.GetRooms(DDLbuilding.SelectedValue)

        'Fill DataTable
        For Each RoomRow In RoomTable
            dtRooms.Rows.Add()
            dtRooms.Rows(dtRooms.Rows.Count - 1)("Room") = RoomRow.Room
        Next

        'bind DDLroom to datatable
        DDLroom.DataSource = dtRooms
        DDLroom.DataBind()
    End Sub


but when the comboBox or DDL is in a gridview it throws the error "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control".

Here's what I have so far for the gridview comboBox

Protected Sub cbEQName_SelectedIndexChanged(sender As Object, e As EventArgs)

     'Get row index of selected comboBox
     Dim gvRow As GridViewRow = CType(CType(sender, Control).Parent.Parent, GridViewRow)
     Dim index As Integer = gvRow.RowIndex

     'Get selected value of selected comboBox
     EQname = TryCast(GVnewEquipment.Rows(index).FindControl("cbEQname"), AjaxControlToolkit.ComboBox).Text

     'Get new values of next comboBox from selected value of selected comboBox
     EquipmentTable = EquipmentAdapter.GetMfg(EQname)

     'Create DataTable
     Dim dtMfgs As New DataTable() ' - mfgs that are used by Equiptment name
     dtMfgs.Columns.Add("mfg", Type.GetType("System.String"))

     'Fill DataTable
     For Each EquipmentRow In EquipmentTable
         dtMfgs.Rows.Add()
         dtMfgs.Rows(dtMfgs.Rows.Count - 1)("mfg") = EquipmentRow.mfg
     Next

     'create ComboBox which will represent GVnewQuipment cbMfg comboBox
     Dim CB = DirectCast(GVnewEquipment.Rows(index).FindControl("cbMfg"), AjaxControlToolkit.ComboBox)

     'bind cbMfg to datatable
     CB.DataSource = dtMfgs
     CB.DataBind()

 End Sub


Any and help is greatly appreciated!!
Lee

Updating two related tables in asp.net core

$
0
0
I'm implementing asp.net core project. In my Controller class, in its Edit method, I wrote some code like below:

public async Task<IActionResult> Edit(int id, ApplicantViewModel applicant)
    {
        var formerApplicantType = await _context.Applicant
            .Include(a => a.ApplicantTypeNavigation)
            .FirstOrDefaultAsync(m => m.ApplicantId == id);

        if (id != applicant.applicantvm.ApplicantId)
        {
            return NotFound();
        }

        if (ModelState.IsValid)
        {
            try
            {
                if (applicant.applicantvm.ApplicantType == 1)
                {
                    var UpdQuery = from a in _context.Applicant
                                   join p in _context.PersonApplicant on a.ApplicantId
                                   equals p.ApplicantId
                                   where applicant.applicantvm.ApplicantId == a.ApplicantId && applicant.applicantvm.ApplicantType == a.ApplicantType
                                   select new { a, p };

                    if (formerApplicantType.ApplicantType == 2)
                    {
                        Debug.WriteLine("opposite applicantType");

                        var legalApplicantForDelete = await _context.LegalApplicant.FindAsync(id);
                        _context.LegalApplicant.Remove(legalApplicantForDelete);

                        //?????
                        var pa = new PersonApplicant()
                        {
                            BirthCertificateNo = applicant.personapplicantvm.BirthCertificateNo,
                            IssuePlace = applicant.personapplicantvm.IssuePlace,
                            NationalCode = applicant.personapplicantvm.NationalCode,
                            Username = applicant.personapplicantvm.Username,
                            Applicant = applicant.applicantvm
                        };
                        using (var context = new CSSDDashboardContext())
                        {
                            context.PersonApplicant.Add(pa);
                            context.SaveChanges();
                        }
                    }
                    else
                    {


                        //----------------------------------------------
                        foreach (var x in UpdQuery.ToList())
                        {
                            x.a.ApplicantType = applicant.applicantvm.ApplicantType;
                            x.a.Address = applicant.applicantvm.Address;
                            x.a.Description = applicant.applicantvm.Description;
                            x.a.Name = applicant.applicantvm.Name;
                            x.p.BirthCertificateNo = applicant.personapplicantvm.BirthCertificateNo;
                            x.p.NationalCode = applicant.personapplicantvm.NationalCode;
                            x.p.IssuePlace = applicant.personapplicantvm.IssuePlace;
                            x.p.Username = applicant.personapplicantvm.Username;

                        }
                    }

                await _context.SaveChangesAsync();

            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ApplicantExists(applicant.applicantvm.ApplicantId))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }
            return RedirectToAction(nameof(Index));
        }
        ViewData["ApplicantType"] = new SelectList(_context.EntityType, "Id", "Id", applicant.applicantvm.ApplicantType);
        return View(applicant);
    }


In my code I have 3 tables Applicant and PersonApplicant and LegalApplicant. Applicant has one to one relationship with LegalApplicant and PersonApplicant. Eachtime Applicant refers to one of them. They are connected with each other as the primary key {ApplicantID,ApplicantType} and if ApplicantType is 1, Applicant refers to PersonApplicant and if it is 2, Applicant refers to LegalApplicant. In the view, the user should choose from a selectlist about the type of applicant he wants to update. Now my problem is in updating those tables when user wants to change the ApplicantType. For instance, if the user change ApplicantType from LegalApplicant to PersonApplicant then the former record in Legal applicant should be deleted according what I did in the code and a new record should be inserted into PersonApplicant. For doing that I wrote like the above code, But after running the project, it shows me an error which is about not to accept the former applicant record exist and just refers to another table. In my methodology I can not delet the related record in Applicant and again insert a new one ther cause I need the former info about that record. I appreciate if anyone guide me how can I fix this.

ASP.Net MVC: When to use HttpGet and when to use HttpPost for action

$
0
0
many time i create action in controller and decorate them with HttpGet or HttpPost verb and call those action by jquery ajax and action return json to client side. i got no difference when i change from HttpGet or HttpPost for any specific action.

so i am curious to know when i should use only HttpGet verb and when HttpPost verb for actions in controller ?

also tell me the difference between response travel in case of HttpGet or HttpPost ?

i know the difference between Get & Post
------------------------------------------
Both GET and POST method is used to transfer data from client to server in HTTP protocol but Main difference between POST and GET method is that GET carries request parameter appended in URL string while POST carries request parameter in message body which makes it more secure way of transferring data

but do not aware the difference between HttpGet or HttpPost verb. so please discuss with a example action which guide me when to use HttpGet and when to use HttpPost.

waiting for good guide line. thanks

returning null value from populated selectlist with DB data

$
0
0
I'm implementing asp.net core MVC project. In my controller class called ApiApplicant, Create method, I have 3 selectlists that its items should be populated from a table called APIApplicantHistory. My models and create method and view are implemented like following:


using System.Collections.Generic;

namespace CSDDashboard.Models
{
public partial class Apiapplicant
{
public Apiapplicant()
{
ApiApplicantHistory = new HashSet<apiapplicanthistory>();
}

public int Id { get; set; }
public string ApiRequestDate { get; set; }
public int? ApiRequestNo { get; set; }
public int? Apiid { get; set; }
public int? ApplicantId { get; set; }
public int? GateId { get; set; }
public string NocRequestDate { get; set; }
public string NocRequestNo { get; set; }
public string Url { get; set; }
public string Description { get; set; }
public bool? IsDeleted { get; set; }

public virtual Api Api { get; set; }
public virtual Applicant Applicant { get; set; }
public virtual Gate Gate { get; set; }
public virtual ICollection<apiapplicanthistory> ApiApplicantHistory { get; set; }
}
}

using System;
using System.Collections.Generic;

namespace CSDDashboard.Models
{
public partial class ApiApplicantHistory
{
public int Id { get; set; }
public int? ApiApplicantId { get; set; }
public string Date { get; set; }
public int? SentResponseType { get; set; }
public int? UnconfirmedReason { get; set; }
public int LastReqStatus { get; set; }
public string Description { get; set; }

public virtual Apiapplicant ApiApplicant { get; set; }
public virtual EntityType LastReqStatusNavigation { get; set; }
public virtual EntityType SentResponseTypeNavigation { get; set; }
public virtual EntityType UnconfirmedReasonNavigation { get; set; }
}
}


using System;
using System.Collections.Generic;

namespace CSDDashboard.Models
{
public partial class EntityType
{
public EntityType()
{
ApiApplicantHistoryLastReqStatusNavigation = new HashSet<apiapplicanthistory>();
ApiApplicantHistorySentResponseTypeNavigation = new HashSet<apiapplicanthistory>();
ApiApplicantHistoryUnconfirmedReasonNavigation = new HashSet<apiapplicanthistory>();
}

public int Id { get; set; }
public string Name { get; set; }
public string EntityKey { get; set; }

public virtual ICollection<apiapplicanthistory> ApiApplicantHistoryLastReqStatusNavigation { get; set; }
public virtual ICollection<apiapplicanthistory> ApiApplicantHistorySentResponseTypeNavigation { get; set; }
public virtual ICollection<apiapplicanthistory> ApiApplicantHistoryUnconfirmedReasonNavigation { get; set; }

}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CSDDashboard.Models
{
public class APIApplicantViewModel
{
public Apiapplicant apiApplicantvm { get; set; }

public ApiApplicantHistory apiApplicantHistoryvm { get; set; }
}
}


public class ApiapplicantsController : Controller
{
private readonly CSSDDashboardContext _context;

public ApiapplicantsController(CSSDDashboardContext context)
{
_context = context;
}

public IActionResult Create()
{

ViewData["sentResponseType"] = new SelectList(_context.EntityType.Where(g => g.EntityKey == "sentResponseType")
        .Include(x => x.ApiApplicantHistoryLastReqStatusNavigation).ToList(), "ID", "name");

ViewData["unconfirmedReason"] = new SelectList(_context.EntityType.Where(g => g.EntityKey == "unconfirmedReason").ToList(), "ID", "name");
ViewData["lastReqStatus"] = new SelectList(_context.EntityType.Where(g => g.EntityKey == "lastRequestStatus").ToList(), "ID", "name");

return View();

}
}

And a part of create view implementation:



@modelCSDDashboard.Models.APIApplicantViewModel

@{
ViewData["Title"] = "create";
}






























@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

In create method, all the viewData are filled with the correct related data but the problem is existing in Create view, after running the project an error like below is shown in Create page:

An unhandled exception occurred while processing the request.
NullReferenceException: Object reference not set to an instance of an object.

After debugging the code I understand that In create view, apiApplicantvm is not null but
ViewBag.sentResponseType
returns null and the above error is because of that. I appreciate if anyone could tells me how to fix the problem.

Dropdown Filtering in grideview vb.net

$
0
0
I am trying to apply filters from one dropdown in a datagrid to another dropdown in the same datagrid and same row. The "edit" screen shot is the most important.

The dropdown under "Chamber" will be used to filter the values in the "District" dropdown. Basically, the "Districts" are tied to a "Chamber". I am having a lot of trouble because of the EditItemTemplate sections.

Thank you for the help in advance!

<!--Term Start--><asp:GridViewCssClass="datatable"ShowFooter="false"ShowHeaderWhenEmpty="true"DataKeyNames="ProfileTermID"DataSourceID="ldsTerms"ID="gvTerms"OnDataBound= "OnDataBound"OnRowCommand="gvTerms_RowCommand"runat="server"AutoGenerateColumns="False"><HeaderStyleBackColor="#999999"ForeColor="#ffffff"/><RowStyleCssClass="divRow"/><EditRowStyleBackColor="#b3d4e8"Height="50px"VerticalAlign="Middle"HorizontalAlign="Center"/><FooterStyleBackColor="#b3d4e8"Height="50px"VerticalAlign="Middle"HorizontalAlign="Center"/><EmptyDataTemplate>
                                       Legislator Has No Terms</EmptyDataTemplate><Columns><asp:BoundFieldDataField="ProfileID"HeaderText="ProfileID"/><asp:TemplateFieldHeaderText="Term Start Date"ItemStyle-CssClass="divCell"><EditItemTemplate><telerik:RadDatePickerID="rdtTermStart"Skin="Metro"runat="server"SelectedDate='<%#Eval("TermStartDate")%>'></telerik:RadDatePicker></EditItemTemplate><ItemTemplate><%#Eval("TermStartDate", "{0:d}")%></ItemTemplate><FooterTemplate><telerik:RadDatePickerID="rdtTermStartF"Skin="Metro"runat="server"></telerik:RadDatePicker></FooterTemplate></asp:TemplateField><asp:TemplateFieldHeaderText="TermEndDate"ItemStyle-CssClass="divCell"><EditItemTemplate><telerik:RadDatePickerID="rdtTermEnd"Skin="Metro"runat="server"Width="200px"SelectedDate='<%# IIf(IsDBNull(Eval("TermEndDate")), vbNull, Eval("TermEndDate"))    %>'/></EditItemTemplate><ItemTemplate><%# IIf(IsDBNull(Eval("TermEndDate")), vbNull, Eval("TermEndDate", "{0:d}"))    %></ItemTemplate><FooterTemplate><telerik:RadDatePickerID="rdtTermEndF"Skin="Metro"runat="server"></telerik:RadDatePicker></FooterTemplate></asp:TemplateField><asp:TemplateFieldHeaderText="Chamber"ItemStyle-CssClass="divCell"><EditItemTemplate><asp:DropDownListID="ddChamber"DataSourceID="ldsChambers"DataTextField="Name"DataValueField="ID"runat="server"AutoPostBack="true"OnSelectedIndexChanged="ddChamber_SelectedIndexChanged"SelectedValue='<%# Bind("ChamberID") %>'></asp:DropDownList></EditItemTemplate><ItemTemplate><%#Eval("mod_chamber.Name")%></ItemTemplate><FooterTemplate><asp:DropDownListID="ddChamberF"AutoPostBack="true"OnSelectedIndexChanged="ddChamberF_SelectedIndexChanged"DataSourceID="ldsChambers"DataTextField="Name"DataValueField="ID"runat="server"></asp:DropDownList></FooterTemplate></asp:TemplateField><asp:TemplateFieldHeaderText="Party"ItemStyle-CssClass="divCell"><EditItemTemplate><asp:DropDownListID="ddParty"DataSourceID="ldsParties"DataTextField="Name"DataValueField="ID"runat="server"SelectedValue='<%# Bind("PartyID") %>'></asp:DropDownList></EditItemTemplate><ItemTemplate><%#Eval("mod_party.name")%></ItemTemplate><FooterTemplate><asp:DropDownListID="ddPartyF"DataSourceID="ldsParties"DataTextField="Name"DataValueField="ID"runat="server"></asp:DropDownList></FooterTemplate></asp:TemplateField><asp:TemplateFieldHeaderText="District"ItemStyle-CssClass="divCell"><EditItemTemplate><asp:DropDownListID="ddDistrict"DataSourceID="ldsDistricts"DataTextField="Name"DataValueField="ID"runat="server"></asp:DropDownList></EditItemTemplate><ItemTemplate><%#Eval("mod_district.name")%></ItemTemplate><FooterTemplate><asp:DropDownListID="ddDistrictF"DataTextField="Name"DataValueField="ID"runat="server"></asp:DropDownList></FooterTemplate></asp:TemplateField><asp:TemplateFieldHeaderText="County"ItemStyle-CssClass="divCell"><EditItemTemplate><asp:DropDownListID="ddCounty"DataSourceID="ldsCounty"DataTextField="Name"DataValueField="ID"runat="server"SelectedValue='<%# Bind("CountyID") %>'></asp:DropDownList></EditItemTemplate><ItemTemplate><%#Eval("mod_county.name")%></ItemTemplate><FooterTemplate><asp:DropDownListID="ddCountyF"DataSourceID="ldsCounty"DataTextField="Name"DataValueField="ID"runat="server"></asp:DropDownList></FooterTemplate></asp:TemplateField><asp:TemplateFieldHeaderText=""ShowHeader="False"ItemStyle-CssClass="divCell"ItemStyle-Height="34px"><EditItemTemplate><asp:ImageButtonID="ImageButton6"runat="server"CausesValidation="False"CommandName="Update"Text="Update"ToolTip="Update"ImageUrl="/admin/images/success.png"/></EditItemTemplate><FooterTemplate><asp:ImageButtonID="ImageButton3"runat="server"CausesValidation="False"CommandName="Insert"ToolTip="Insert"Text="Insert"ImageUrl="/admin/images/success.png"/></FooterTemplate><ItemTemplate><asp:ImageButtonID="ImageButton1"runat="server"CausesValidation="False"CommandName="Edit"Text="Edit"ImageUrl="/admin/images/ico_edit_a.png"/></ItemTemplate></asp:TemplateField><asp:TemplateFieldHeaderText=""ShowHeader="False"ItemStyle-CssClass="divCell"ItemStyle-Height="34px"><ItemTemplate><asp:ImageButtonID="ImageButton2"runat="server"CausesValidation="False"CommandName="Delete"Text="Delete"ImageUrl="/admin/images/ico_delete_a.png"/></ItemTemplate><EditItemTemplate><asp:ImageButtonID="ImageButton3"runat="server"CausesValidation="False"CommandName="Cancel"Text="Cancel"ImageUrl="/admin/images/ico_subtract.png"/></EditItemTemplate><FooterTemplate><asp:ImageButtonID="ImageButton7"runat="server"CausesValidation="False"CommandName="Cancel_New"Text="Cancel"ImageUrl="/admin/images/ico_subtract.png"/></FooterTemplate></asp:TemplateField></Columns></asp:GridView></div></div><asp:LinqDataSourceID="LinqDataSource1"runat="server"ContextTypeName="CMSmodules.modulesDataContext"TableName="mod_Profiles"EnableDelete="True"></asp:LinqDataSource><asp:LinqDataSourceID="LinqDataSource2"runat="server"ContextTypeName="CMSmodules.modulesDataContext"EnableInsert="True"EnableUpdate="True"TableName="mod_Profiles"Where="ID == @ID"><WhereParameters><asp:ControlParameterControlID="lvContent"DefaultValue="0"Name="ID"PropertyName="SelectedValue"Type="Int32"/></WhereParameters></asp:LinqDataSource><asp:LinqDataSourceID="ldsTerms"runat="server"ContextTypeName="CMSmodules.ModulesDataContext"EntityTypeName=""TableName="mod_ProfileTerms"EnableDelete="True"EnableInsert="True"EnableUpdate="True"></asp:LinqDataSource><asp:LinqDataSourceID="ldsDistricts"runat="server"ContextTypeName="CMSmodules.modulesDataContext"TableName="mod_Districts"OrderBy="Name"Select="new (ID, Name)"></asp:LinqDataSource><asp:LinqDataSourceID="ldsParties"runat="server"ContextTypeName="CMSmodules.modulesDataContext"TableName="mod_Parties"OrderBy="Name"Select="new (ID, Name)"></asp:LinqDataSource><asp:LinqDataSourceID="ldsChambers"runat="server"ContextTypeName="CMSmodules.modulesDataContext"TableName="mod_Chambers"OrderBy="Name"Select="new (ID, Name)"></asp:LinqDataSource><asp:LinqDataSourceID="ldsCounty"runat="server"ContextTypeName="CMSmodules.modulesDataContext"TableName="mod_Counties"OrderBy="Name"Select="new (ID, Name)"></asp:LinqDataSource><asp:LinqDataSourceID="ldsSessions"runat="server"ContextTypeName="CMSmodules.modulesDataContext"TableName="mod_Sessions"OrderBy="Name"Select="new (ID, Name)"></asp:LinqDataSource>

Writing a client app for OData

$
0
0
Hi, I am new to the OData World - I am researching, I have been given a task to connect to OData Services they have, they are exposing their Data through OData - that's what I understood, based upon that I have to write an ASP.Net client application, they have given URLs to connect to their OData Services, now I want to understand couple of things before I start writing my client app.

1. What's the use of exposing Data as OData over other web/rest services, why do we need it? Are there any security advantages?
2. What are the best ways to connect to OData Service from client like Entity Framework is better or just use .Net C#?
3. What precautions should I take when I am connecting and using a OData Service?
4. Any other suggestions you can give me would be very very appreciated - thanks a lot. I am also researching about it, but if you know something already also would be helpful - thanks again.

(SOLVED) Any ideas why gridview is not getting populated with data from the database?

$
0
0
Hello experts,

We have an app that prompts employees to enter his/her empID.

Once the employee enters his/her ID, the VB/Stored Proc checks the ID to determine if user has entered his/her information from previous year.

If no, the user gets a blank page to enter his/her data.

If user had entered data the previous year, our objective is to have data populate the GridView control giving the user the opportunity to review data and make changes if necessary.

The code largely works when populating data outside of GridView.

However, GridView is not getting populated with the two sourcename and spousename.

Obviously, it is not recognizing textboxes from GridView.

Any ideas how to resolve this?

My abbreviated code below. Thanks a lot in advnce

Sorry for the long code.

Stored Proc
ALTER PROCEDURE [dbo].[ValidateEmpID]
@empID varchar(50)
AS
BEGIN
SET NOCOUNT OFF;
SELECT employeeName, email, emptitle, EmpID,
    CASE WHEN YEAR(d.dateCreated) = YEAR(getdate()) -1 THEN 1 ELSE 0 END as previousYear, 
    CASE WHEN YEAR(d.dateCreated) = YEAR(getdate()) THEN 1 ELSE 0 END as thisYear 
    FROM Employees e 
    INNER JOIN dateDetails d on e.employeeID = d.EmployeeID 
    INNER JOIN SourceDetails so on e.employeeID = so.EmployeeID
	INNER JOIN SpouseDetails sp on e.employeeID = sp.employeeID 
    WHERE EmpID=@empID
 END

//HTML

  <div class="table-responsive"><table class="table"><tr><td><div class="form-group"><label for="lblEname"><span style="font-weight:bold;font-size:16px;color:#000000;">Employee Name</span><span style="color:#ff0000">*</span></label><asp:TextBox ID="txteName" placeholder="Employee name..." style="width:200px;" class="form-control" runat="server"></asp:TextBox><asp:RequiredFieldValidator id="RequiredFieldValidator2" Font-Bold="true" 
	 SetFocusOnError="true" runat="server" 
	 ErrorMessage="*" ControlToValidate="txteName" /><br /></div></td><td><div class="form-group"><label id="lblTitle"><span style="font-weight:bold;font-size:16px;color:#000000;">Your title</span><span style="color:#ff0000">*</span></label><asp:TextBox ID="txttitle" placeholder="Employee title..." style="width:200px;" class="form-control" runat="server"></asp:TextBox><asp:RequiredFieldValidator id="RequiredFieldValidator3" Font-Bold="true" 
	   SetFocusOnError="true" runat="server" 
	 ErrorMessage="*" ControlToValidate="txttitle" /></div> </td><td><div class="form-group"><label id="lblEmail"><span style="font-weight:bold;font-size:16px;color:#000000;">Your email address</span><span style="color:#ff0000">*</span></label><asp:TextBox ID="txtemail" placeholder="Employee email..." style="width:200px;" class="form-control" runat="server"></asp:TextBox><asp:RequiredFieldValidator id="RequiredFieldValidator4" Font-Bold="true" 
	SetFocusOnError="true" runat="server" 
	ErrorMessage="*" ControlToValidate="txtemail" /></div></td></tr></table></div><table class="table"><tr><td><asp:gridview ID="Gridview1" RowStyle-Wrap="false" gridlines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" onrowdatabound="Gridview1_RowDataBound" OnRowDeleting="Gridview1_RowDeleting"><Columns><asp:BoundField DataField="RowNumber" Visible="false" HeaderText="Row Number" /><asp:TemplateField HeaderText="Name"><headerstyle horizontalalign="Left" /><ItemTemplate><asp:TextBox ID="txtsourcename" Text='<%# Eval("sourcename") %>' placeholder="Name...(e.g, Jane Doe)" runat="server" style="width:375px;" AutoPostBack="true" class="form-control textClass" OnTextChanged="txtsourcename_TextChanged"></asp:TextBox><br /><asp:CheckBox ID="grid1Details" ClientIDMode="Static" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="Grid1CheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Address"><ItemStyle HorizontalAlign="Left"></ItemStyle><ItemTemplate><asp:TextBox ID="txtsourceaddress" Text='<%# Eval("sourceaddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control textClass"></asp:TextBox><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText=""><ItemTemplate><asp:Button ID="ButtonAdd" runat="server" Text="Add another row if needed" 
		onclick="ButtonAdd_Click" CssClass="grvAddButton" /><br /><br /><br></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText=""><ItemTemplate><asp:Button ID="sourceDelete" runat="server" Text="Delete" CommandName="Delete"
		 CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')"  /> <br /><br /><br /></ItemTemplate></asp:TemplateField> </Columns></asp:gridview></td></tr></table>
//VB
Protected Sub txtEmpID_TextChanged(sender As Object, e As EventArgs) Handles txtEmpID.TextChanged
  If Not String.IsNullOrEmpty(txtEmpID.Text) Then
      Dim Conn As SqlConnection
      'Read in connection String
      Conn = New SqlConnection(ConfigurationManager.ConnectionStrings("constr").ConnectionString)
      Conn.Open()
      Dim cmd As New SqlCommand("ValidateEmpID", Conn)
      cmd.CommandType = CommandType.StoredProcedure
      cmd.Parameters.AddWithValue("@empID", txtEmpID.Text)
      Dim dr As SqlDataReader = cmd.ExecuteReader()
      If dr.HasRows Then
	  'Employee exists'
	  dr.Read()
	  checkusername.Visible = True
	  dprocessed.Visible = True
	  If dr("previousYear").ToString() = "1" Then
	      imgstatus.ImageUrl = "images/NotAvailable.jpg"
	      lblStatus.Text = "Please verify your information for accuracy. Then complete rest of the form."
	      lblStatus.ForeColor = System.Drawing.Color.Red
	      System.Threading.Thread.Sleep(300)
	      txteName.Text = dr("employeeName").ToString()
	      txttitle.Text = dr("empTitle").ToString()
	      txtemail.Text = dr("email").ToString()
	      txtEmpID.Text = dr("empID").ToString()

	      Dim currentRow As GridViewRow = CType((CType(sender, TextBox)).Parent.Parent.Parent.Parent, GridViewRow)
	      Dim txtsource As TextBox = CType(currentRow.FindControl("txtsourcename"), TextBox)
	      txtsource.Text = dr("sourcename").ToString()
	      Dim txtsource As TextBox = CType(currentRow.FindControl("txtspousename"), TextBox)
	      txtspouse.Text = dr("spousename").ToString()                      

	  ElseIf dr("thisYear").ToString() = "1" Then
	      imgstatus.ImageUrl = "images/NotAvailable.jpg"
	      lblStatus.Text = "You have already completed this Disclosure form. Please close the form. If you feel there is a mistake, please contact Clerk at xxx-xxx-xxxx"
	      lblStatus.ForeColor = System.Drawing.Color.Red
	      System.Threading.Thread.Sleep(300)
	      txteName.Text = dr("employeeName").ToString()
	      txttitle.Text = dr("empTitle").ToString()
	      txtemail.Text = dr("email").ToString()
	      txtEmpID.Text = dr("empID").ToString()
	      txteName.Enabled = False
	      txttitle.Enabled = False
	      txtemail.Enabled = False
	      txtEmpID.Enabled = False
	      GridPanels.Enabled = False
	      dprocessed.Visible = True
	      btnNext.Enabled = False
	  Else
	      'not this year, nor the previous year'
	  End If
      Else
	  checkusername.Visible = True
	  dprocessed.Visible = True
	  imgstatus.ImageUrl = "images/Icon_Available.gif"
	  lblStatus.Text = "Proceed to complete entire form"
	  lblStatus.ForeColor = System.Drawing.Color.Red
	  System.Threading.Thread.Sleep(300)
	  txteName.Text = ""
	  txttitle.Text = ""
	  txtemail.Text = ""
      End If
  Else
      checkusername.Visible = False
  End If
End Sub

HTTP Error 500.19 - Internal Server Error - The requested page cannot be accessed because the related configuration data for the page is invalid

$
0
0
Hi I am getting the following error when I changed the path of the application - from source control, source control took the latest version of the application but started giving me the following error - any help please? This is the error messages that I am getting

Detailed Error Information:
Module	   WindowsAuthenticationModule
Notification	   AuthenticateRequest
Handler	   ExtensionlessUrlHandler-Integrated-4.0
Error Code	   0x80070021
Config Error	   This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
Config File	   \\?\C:\SrcCode\IMS\Development\IMS\IMS.Web\web.config


Config Source:
   99:         <anonymousAuthentication enabled="true" />
  100:         <windowsAuthentication enabled="true" />
  101:       </authentication>

More Information:
This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error.
If you see the text "There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined", this error is because you are running a .NET Framework 3.5-based application in .NET Framework 4. If you are running WebMatrix, to resolve this problem, go to the Settings node to set the .NET Framework version to ".NET 2". You can also remove the extra sections from the web.config file.
View more information »


Any help please - its urgent - thanks in advance please

When string in a cell has double quotes those appear in Excel after export. How do I remove them?

$
0
0
I need help to fix an issue where when data from web application is exported to Excel by clicking a button export to excel, if the data in a cell contains double quotes, that data should be displayed without the double quotes visible.

Previously I made a change to the application code in VB so that the output exports text fields with formulas (="") to force Excel to treat those values as a string. This has been working except some instances where the output actually displays the formula characters (="") within the cell as text, rather than as hidden formulas. It appears when a cell contains text with an actual double quotes that is when after export to Excel is done, those quotes appear in Excel. I need help to figure out if there is a way to suppress those.

For example. A cell with the following data Allows the user the abilities to Add, View, Modify and Delete Notes on the Notes Tab of the Case Record. "View" allows the user to view the Notes Tab of the Case Record.

When this is exported to Excel the data is displayed as follows ="Allows the user the abilities to Add, View, Modify and Delete Notes on the Notes Tab of the Case Record. "View" allows the user to view the Notes Tab of the Case Record. I do not want to quotes to appear in Excel.

On the other hand, a cell with the following data Maintain Victim Classification Types. when this is exported to Excel there are no visible quotes. It displays as Maintain Victim Classification Types.

Here is my VB code that needed changing

ProtectedSub WriteToExcelFile(dt As DataTable)'This method exports the resulting query datatable to an instance of Excel using StringWriterIfNot dt IsNothingThenDim sw AsNew StringWriter()'Loop through the column names and output those firstForEach datacol As DataColumn In dt.Columns
            sw.Write(datacol.ColumnName + vbTab)NextDim row As DataRow'Loop through the datatable's rowsForEach row In dt.Rows'Newline between the previous row and the next row
            sw.Write(vbNewLine)Dim column AsNew DataColumn()'Loop through each column and write the cell the the stringwriterForEach column In dt.Columns'If the cell isn't empty write it, else write an empty cellIfNot row(column.ColumnName) IsNothingThen
					sw.Write("="""& row(column).ToString().Trim() & """"& vbTab)Else
                        sw.Write(String.Empty + vbTab)EndIfNext columnNext row'create an instance of Excel and write the data
            Response.Clear()
            Response.ContentType = "application/vnd.ms-excel"
            Response.AddHeader("Content-Disposition", "attachment;filename=GridViewExport.xls")
            Response.Output.Write(sw.ToString())
            Response.Flush()
            System.Web.HttpContext.Current.Response.Flush()
            System.Web.HttpContext.Current.Response.SuppressContent = True
            System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest()EndIfEndSub

ASP.NET + Multi Form using Textbox problem

$
0
0
Hi Sir,

Need help, i noob in Asp.net. Using VB for my coding;

Situation :-

a) Using Master Page 
b) Got 3 web Form ( Staff.aspx,student.aspx,external.aspx)
c) Every form have Search Textbox

In Staff.aspx, search Textbox working great when connecting to Oracle Database and appear the data holder in other textbox.
But when using Student.aspx or External.aspx, the Search Textbox will appear No Data / Cardholder , in database the data is exist.
the Sql query it ok when i direct include the User ID but when keep in in textbox cannot appear the data.

Plz guide me

Tq

Some GridView controls are running empty rows. Any ideas to fix

$
0
0
Greetings again,

Please forgive me for posting too much code. I am trying to post something that gives an idea of what I am struggling with.

Looking at the code, you can see there are 7 controls, GridView1, gvspouse, etc.

When the user queries the DB and there is say one row of data for say GridView1, the rest of the controls display one row of data. This is fine.

However, if the query returns two or more rows of data for one control, usually the rest of controls will show two or more empty rows of data.

This is not good.

We would like only the controls with two or more rows of data to return those rows and those controls that don't have any data to return just one row so user can fill that row if need be or leave it empty.

Is this possible?

Again, I apologize for too much code. My hope is that it helps convey the point I am trying to make when I say seven GridView controls.

Many thanks in advance

/HTML<asp:UpdatePanel ID="PnlUsrDetails" runat="server"><ContentTemplate><asp:MultiView ID="myMultiView" ActiveViewIndex="0" runat="server"><asp:View ID="vwPersonalData" runat="server"><!-- All user textboxes for input here --><span style="font-weight:bold;font-size:18px;color:#000000;">Name, title, and email address of employee filling this form</span><br /><br /><div><div class="table-responsive"><tablecccc><tr><td><div class="form-group"><label id="lblEmpID"><span style="font-weight: bold; font-size: 16px; color: #000000;">Enter your Employee Id to begin</span><span
                                style="color: #ff0000">*</span></label><asp:TextBox ID="txtEmpID" maxlength="10" placeholder="Badge ID..." Style="width: 150px;" class="form-control"
                            runat="server" AutoPostBack="true" OnTextChanged="txtEmpID_TextChanged"></asp:TextBox><br /></div></td><td><div class="bd-callout bd-callout-danger" id="dprocessed" style="width:90%;" runat="server" visible="false"><div id="checkusername" runat="server" visible="false" style="white-space:nowrap"><asp:Label ID="lblStatus" runat="server"></asp:Label><asp:Image ID="imgstatus" runat="server" Width="17px" Height="17px" /></div></div><div class="waitingdiv" id="loadingdiv" style="display:none;margin-left:5.3em"><img src="images/ajax-loader.gif" alt="Loading" />Please wait...</div></td></tr></tablecccc></div><div class="bd-callout bd-callout-danger" style="width:70%;"><span style="color:#0093B2;font-weight:bold;font-size:1em;"> If you do not have an Employee ID, use the First Initial of first name + first initial of Last Name + date of birth in the format of MMDDYYYY. (For example, John Doe born January 1, 1900 will be, JD01011900)</span></div><br /><br /><div class="table-responsive"><table class="table"><tr><td><div class="form-group"><label for="lblEname"><span style="font-weight:bold;font-size:16px;color:#000000;">Employee Name</span><span style="color:#ff0000">*</span></label><asp:TextBox ID="txteName" placeholder="Employee name..." style="width:200px;" class="form-control" runat="server"></asp:TextBox><asp:RequiredFieldValidator id="RequiredFieldValidator2" Font-Bold="true" 
                 SetFocusOnError="true" runat="server" 
                 ErrorMessage="*" ControlToValidate="txteName" /><br /></div></td><td><div class="form-group"><label id="lblTitle"><span style="font-weight:bold;font-size:16px;color:#000000;">Your title</span><span style="color:#ff0000">*</span></label><asp:TextBox ID="txttitle" placeholder="Employee title..." style="width:200px;" class="form-control" runat="server"></asp:TextBox><asp:RequiredFieldValidator id="RequiredFieldValidator3" Font-Bold="true" 
                   SetFocusOnError="true" runat="server" 
                 ErrorMessage="*" ControlToValidate="txttitle" /></div> </td><td><div class="form-group"><label id="lblEmail"><span style="font-weight:bold;font-size:16px;color:#000000;">Your email address</span><span style="color:#ff0000">*</span></label><asp:TextBox ID="txtemail" placeholder="Employee email..." style="width:200px;" class="form-control" runat="server"></asp:TextBox><asp:RequiredFieldValidator id="RequiredFieldValidator4" Font-Bold="true" 
                SetFocusOnError="true" runat="server" 
                ErrorMessage="*" ControlToValidate="txtemail" /></div></td></tr></table></div><br /><br /><div id="mainContainer" class="container">   <div class="shadowBox">   <div class="page-container">   <div class="container">   <div class="row">   <div class="col-lg-12 ">   <div class="table-responsive" data-pattern="priority-columns"><span style="font-weight:bold;font-size:18px;color:#000000;">1. Name and address of Income Sources of $1,000.00 or greater of Employee (excluding income received from the organization):</span><br /><br />    <table class="table"><tr><td><asp:gridview ID="Gridview1" RowStyle-Wrap="false" gridlines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" onrowdatabound="Gridview1_RowDataBound" OnRowDeleting="Gridview1_RowDeleting"><Columns><asp:BoundField DataField="RowNumber" Visible="false" HeaderText="Row Number" /><asp:TemplateField HeaderText="Name"><headerstyle horizontalalign="Left" /><ItemTemplate><asp:TextBox ID="txtsourcename" Text='<%# Eval("sourcename") %>' placeholder="Name...(e.g, Jane Doe)" runat="server" style="width:375px;" AutoPostBack="true" class="form-control textClass" OnTextChanged="txtsourcename_TextChanged"></asp:TextBox><br /><asp:CheckBox ID="grid1Details" ClientIDMode="Static" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="Grid1CheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Address"><ItemStyle HorizontalAlign="Left"></ItemStyle><ItemTemplate><asp:TextBox ID="txtsourceaddress" Text='<%# Eval("sourceaddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control textClass"></asp:TextBox><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText=""><ItemTemplate><asp:Button ID="ButtonAdd" runat="server" Text="Add another row if needed" 
                        onclick="ButtonAdd_Click" CssClass="grvAddButton" /><br /><br /><br></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText=""><ItemTemplate><asp:Button ID="sourceDelete" runat="server" Text="Delete" CommandName="Delete"
                         CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')"  /> <br /><br /><br /></ItemTemplate></asp:TemplateField> </Columns></asp:gridview></td></tr></table><span style="font-weight:bold;font-size:18px;color:#000000;">2. Name and address of Income Sources of $1,000.00 greater of Spouse, if any:</span><button type="button" class="btn btn-info" data-toggle="popover" title="Definition of Spouse" data-trigger="focus" data-content="For purposes of this ordinance, the term spouse includes a domestic partner as the Code of organization defines that term."><span class="glyphicon glyphicon-question-sign" style="color:#ffffff"></span></button><br />                       <table class="table"><tr><td>                     <asp:gridview ID="grvspouse" RowStyle-Wrap="false" GridLines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" onrowdatabound="grvspouse_RowDataBound" OnRowDeleting="grvspouse_RowDeleting"><Columns><asp:BoundField DataField="SpouseNumber" Visible="false" HeaderText="Row Number" /><asp:TemplateField HeaderText="Name"><headerstyle horizontalalign="Left" /><ItemTemplate><asp:TextBox ID="txtspousename" Text='<%# Eval("spousename") %>' placeholder="Name...(e.g, Jane Doe)" runat="server" style="width:375px;" class="form-control" AutoPostBack="true" OnTextChanged="txtspousename_TextChanged"></asp:TextBox><br /><asp:CheckBox ID="spouseDetails" ClientIDMode="Static" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="SpouseCheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Address"><ItemStyle HorizontalAlign="Left"></ItemStyle><ItemTemplate><asp:TextBox ID="txtspouseaddress" Text='<%# Eval("spouseaddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control"></asp:TextBox><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText=""><ItemTemplate><asp:Button ID="ButtonAdd2" runat="server" Text="Add another row if needed" 
                        onclick="ButtonAdd2_Click" CssClass="grvAddButton" /><br /><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText=""><ItemTemplate><asp:Button ID="spouseDelete" runat="server" Text="Delete" CommandName="Delete"
                         CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')"  /> <br /><br /><br /></ItemTemplate></asp:TemplateField> </Columns></asp:gridview></td></tr></table><span style="font-weight:bold;font-size:18px;color:#000000;">3. Name and address of sources of Interest or Dividends of $1,000 or greater of Employee and/or Spouse:</span><br /><br /><table class="table"><tr><td>  <asp:gridview ID="grvDiv" RowStyle-Wrap="false" GridLines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" OnRowDeleting="grvDiv_RowDeleting"><Columns><asp:BoundField DataField="DivsNumber" Visible="false" HeaderText="Row Number" /><asp:TemplateField HeaderText="Name"><headerstyle horizontalalign="Left" /><ItemTemplate><asp:TextBox ID="txtdividentname" Text='<%# Eval("dividentName") %>' placeholder="Name of income or divident source..." runat="server" style="width:375px;" class="form-control" AutoPostBack="true" OnTextChanged="txtdividentname_TextChanged"></asp:TextBox><br /><asp:CheckBox ID="divDetails" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="divCheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Address"><ItemStyle HorizontalAlign="Left"></ItemStyle><ItemTemplate><asp:TextBox ID="txtdividentaddress" Text='<%# Eval("dividentAddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control"></asp:TextBox><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText=""><ItemTemplate><asp:Button ID="ButtonAdd3" runat="server" Text="Add another row if needed" 
                        onclick="ButtonAdd3_Click" CssClass="grvAddButton" /><br /><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText=""><ItemTemplate><asp:Button ID="divDelete" runat="server" Text="Delete" CommandName="Delete"
                         CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')"  /> <br /><br /><br /></ItemTemplate></asp:TemplateField> </Columns></asp:gridview></td></tr></table><span style="font-weight:bold;font-size:18px;color:#000000;">4. Name and address of sources of reimbursement of expenses of $1,000 or greater of Employee and/or Spouse: (excluding reimbursement of expenses by DeKalb County or reimbursement by any insurance program offered by DeKalb County):</span><br /><br />              <table class="table"><tr><td><asp:gridview ID="grvReim" RowStyle-Wrap="false" GridLines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" OnRowDeleting="grvReim_RowDeleting"><Columns><asp:BoundField DataField="ReimNumber" Visible="false" HeaderText="Row Number" /><asp:TemplateField HeaderText="Name"><headerstyle horizontalalign="Left" /><ItemTemplate><asp:TextBox ID="txtReimbursename" Text='<%# Eval("reimbursementName") %>' placeholder="Name of source of reimbursement..." runat="server" style="width:375px;" class="form-control" AutoPostBack="true" OnTextChanged="txtReimbursename_TextChanged"></asp:TextBox><br /><asp:CheckBox ID="reimDetails" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="ReimCheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Address"><ItemStyle HorizontalAlign="Left"></ItemStyle><ItemTemplate><asp:TextBox ID="txtReimburseaddress" Text='<%# Eval("reimbursementAddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control"></asp:TextBox><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField><ItemTemplate><asp:Button ID="ButtonAd4" runat="server" Text="Add another row if needed" 
                        onclick="ButtonAdd4_Click" CssClass="grvAddButton" /><br /><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText=""><ItemTemplate><asp:Button ID="reimnDelete" runat="server" Text="Delete" CommandName="Delete"
                         CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')"  /> <br /><br /><br /></ItemTemplate></asp:TemplateField> </Columns></asp:gridview></td></tr></table><span style="font-weight:bold;font-size:18px;color:#000000;">5. Honoraria from a single source in the aggregate amount of $500.00 or greater:  (No comma (,)  or period(.), eg 500)</span><button type="button" class="btn btn-info" data-toggle="popover" title="Honoraria Definition" data-trigger="focus" data-content="A payment given to a professional person for services for which fees are not legally or traditionally required."><span class="glyphicon glyphicon-question-sign" style="color:#ffffff"></span></button><br /><table class="table"><tr><td><asp:gridview ID="grvHon" RowStyle-Wrap="false" GridLines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" OnRowDeleting="grvHon_RowDeleting"><Columns><asp:BoundField DataField="HonNumber" Visible="false" HeaderText="Row Number" /><asp:TemplateField HeaderText="Honoraria"><headerstyle horizontalAlign="Left" /><ItemTemplate><asp:TextBox ID="txthonoraria" Text='<%# Eval("honoraria") %>' placeholder="Honoraria from a single source... eg 500" runat="server" style="width:250px;" class="form-control txtgiftincome" AutoPostBack="true" OnTextChanged="txthonoraria_TextChanged"></asp:TextBox><br /><asp:CheckBox ID="honDetails" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="HonCheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Address"><ItemStyle HorizontalAlign="Left"></ItemStyle><ItemTemplate><asp:TextBox ID="txthonaddress" Text='<%# Eval("HonorariaAddress") %>' placeholder="Address..." runat="server" style="width:250px;" class="form-control"></asp:TextBox><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Income"><ItemStyle HorizontalAlign="Left"></ItemStyle><ItemTemplate><asp:TextBox ID="txthonincome" Text='<%# Eval("HonorariaIncome") %>' placeholder="Income...(example: 500)" runat="server" style="width:250px;" class="form-control txtgiftincome numeric"></asp:TextBox><asp:CompareValidator ID="valQtyNumeric" runat="server" ControlToValidate="txthonincome" style="color:red;font-weight:bold;font-size:1.0em;" Display="Dynamic" SetFocusOnError="true"
                 Text="" ErrorMessage="Error: Amount must be digits only!" Operator="DataTypeCheck" Type="Integer">              </asp:CompareValidator><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField><ItemTemplate><asp:Button ID="ButtonAdd5" runat="server" Text="Add another row if needed" 
                        onclick="ButtonAdd5_Click" CssClass="grvAddButton" /><br /><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText=""><ItemTemplate><asp:Button ID="HonDelete" runat="server" Text="Delete" CommandName="Delete"
                         CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')"  /> <br /><br /><br /></ItemTemplate></asp:TemplateField> </Columns></asp:gridview></td></tr></table><span style="font-weight:bold;font-size:18px;color:#000000;">6. Name and address of the source of any gift /or gifts in the aggregate amount or value of $500 or greater from a single source: (excluding gifts from relatives unless the relative is doing business with the County):</span><br /><br />             <table class="table"><tr><td><asp:gridview ID="grvGift" RowStyle-Wrap="false" GridLines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" OnRowDeleting="grvGift_RowDeleting"><Columns><asp:BoundField DataField="GiftNumber" Visible="false" HeaderText="Row Number" /><asp:TemplateField HeaderText="Name"><headerstyle horizontalalign="Left" /><ItemTemplate><asp:TextBox ID="txtgiftname" Text='<%# Eval("giftName") %>' placeholder="Name of source of any gift..." runat="server" style="width:375px;" class="form-control" AutoPostBack="true" OnTextChanged="txtgiftname_TextChanged"></asp:TextBox><br /><asp:CheckBox ID="giftDetails" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="GiftCheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Address"><ItemStyle HorizontalAlign="Left"></ItemStyle><ItemTemplate><asp:TextBox ID="txtgiftaddress" Text='<%# Eval("giftAddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control"></asp:TextBox><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField><ItemTemplate><asp:Button ID="ButtonAdd6" runat="server" Text="Add another row if needed" 
                        onclick="ButtonAdd6_Click" CssClass="grvAddButton" /><br /><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText=""><ItemTemplate><asp:Button ID="giftDelete" runat="server" Text="Delete" CommandName="Delete"
                         CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')"  /> <br /><br /><br /></ItemTemplate></asp:TemplateField> </Columns></asp:gridview></td></tr></table><span style="font-weight:bold;font-size:18px;color:#000000;">7. Name and address of any organization in which the employee or spouse is an officer, director, partner, proprietor or serves in any advisory capacity from which the income of $1,000.00 or greater was derived:</span><br /><br />            <table class="table"><tr><td><asp:gridview ID="grvOrg" RowStyle-Wrap="false" GridLines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" OnRowDeleting="grvOrg_RowDeleting"><Columns><asp:BoundField DataField="OrgNumber" Visible="false" HeaderText="Row Number" /><asp:TemplateField HeaderText="Name"><headerstyle horizontalalign="Left" /><ItemTemplate><asp:TextBox ID="txtorgname" Text='<%# Eval("orgName") %>' placeholder="Name of organization..." runat="server" style="width:375px;" class="form-control" AutoPostBack="true" OnTextChanged="txtorgname_TextChanged"></asp:TextBox><br /><asp:CheckBox ID="orgDetails" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="OrgCheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Address"><ItemStyle HorizontalAlign="Left"></ItemStyle><ItemTemplate><asp:TextBox ID="txtorgaddress" Text='<%# Eval("orgAddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control"></asp:TextBox><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField><ItemTemplate><asp:Button ID="ButtonAdd7" runat="server" Text="Add another row if needed" 
                        onclick="ButtonAdd7_Click" CssClass="grvAddButton" /><br /><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText=""><ItemTemplate><asp:Button ID="orgDelete" runat="server" Text="Delete" CommandName="Delete"
                         CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')"  /> <br /><br /><br /></ItemTemplate></asp:TemplateField> </Columns></asp:gridview></td></tr></table><span style="font-weight:bold;font-size:18px;color:#000000;">8. Name and address of each creditor to whom the employee or spouse was indebted for a period of 90 consecutive days or more in an amount of $7,500.00 or greater, excluding the purchase or sale of real property, retail installment debt, vehicle payments and student loans:</span><br /><br />            <table class="table"><tr><td><asp:gridview ID="grvCred" RowStyle-Wrap="false" GridLines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" OnRowDeleting="grvCred_RowDeleting"><Columns><asp:BoundField DataField="CreditNumber" Visible="false" HeaderText="Row Number" /><asp:TemplateField HeaderText="Name"><headerstyle horizontalalign="Left" /><ItemTemplate><asp:TextBox ID="txtcreditorname" Text='<%# Eval("creditorname") %>' placeholder="Name of creditor..." runat="server" style="width:375px;" class="form-control" AutoPostBack="true" OnTextChanged="txtcreditorname_TextChanged"></asp:TextBox><br /><asp:CheckBox ID="credDetails" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="CredCheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Address"><ItemStyle HorizontalAlign="Left"></ItemStyle><ItemTemplate><asp:TextBox ID="txtcreditoraddress" Text='<%# Eval("creditoraddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control"></asp:TextBox><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField><ItemTemplate><asp:Button ID="ButtonAdd8" runat="server" Text="Add another row if needed" 
                        onclick="ButtonAdd8_Click" CssClass="grvAddButton" /><br /><br /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText=""><ItemTemplate><asp:Button ID="credDelete" runat="server" Text="Delete" CommandName="Delete"
                         CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')"  /> <br /><br /><br /></ItemTemplate></asp:TemplateField> </Columns></asp:gridview></td></tr></table></div>   </div>  </div></div></div></div></div></div></asp:View></asp:MultiView></ContentTemplate></asp:UpdatePanel></asp:Panel></form>
//VB
    Private Sub fillSourceRecords()
        Dim control As Control = Nothing
        Dim conn_str As String = ConfigurationManager.ConnectionStrings("ppmtest").ConnectionString
        Using conn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("ppmtest").ConnectionString)
            conn.Open()
            Using sourcecmd As SqlCommand = New SqlCommand()
                sourcecmd.CommandText = "uspGetEthicsRecs"
                sourcecmd.CommandType = CommandType.StoredProcedure
                sourcecmd.Parameters.AddWithValue("@empID", txtEmpID.Text.Trim())
                sourcecmd.Connection = conn
                Using ad As SqlDataAdapter = New SqlDataAdapter(sourcecmd)
                    Dim ds As DataTable = New DataTable()
                    ad.Fill(ds)
                    If ds.Rows.Count > 0 Then
                        Gridview1.DataSource = ds
                        Gridview1.DataBind()
                        grvspouse.DataSource = ds
                        grvspouse.DataBind()
                        grvDiv.DataSource = ds
                        grvDiv.DataBind()
                        grvReim.DataSource = ds
                        grvReim.DataBind()
                        grvHon.DataSource = ds
                        grvHon.DataBind()
                        grvGift.DataSource = ds
                        grvGift.DataBind()
                        grvOrg.DataSource = ds
                        grvOrg.DataBind()
                        grvCred.DataSource = ds
                        grvCred.DataBind()
                    Else
                    End If
                End Using

            End Using
        End Using
    End Sub

Application for creating vector objects

$
0
0
Hi,

could someone advise me what the best technology (SilverLight, etc.) I should use to create a "drawing layout" where I could to insert vector objects (see the link - individual dimensioned blocks, that is air handling unit from blocks) based on user input parameters and the possibility to edit them backwards (parameters, dimensions, ...), add dimensions, etc. ??
http://www.computair.co.uk/Content/images/wintadsprocess/2x3Image5.png[^]

Vectors must be used because I need to know the exact placement of blocks relative to each other, know the exact dimensions, etc. to use for further calculations, create drawings, export DXF files, etc.

In fact, it is a conversion of a desktop application to a web application.

I'd like to stay with ASP.NET and C #.

Thank you very much!
Mitch

Can You Really Use ASP.NET Core 3.1 to Build Production Web Pages/Apps?

$
0
0
Hi, I've been working on a web portal using ASP.NET Core 3.1 and I keep running into weird errors between Identity and EF Core. I've gone through several complete rebuilds and tons of errors and problems. when I build little web apps or separate Identity and EF Core then everything works just dandy. But when I try to bring them all together in a rather large production web app all of a sudden weird bugs crop up.

I've read that the Identity and EF Core teams work separately and sometimes there are problems between their releases...So I am wondering:

Is ASP.NET Core 3.1 not yet ready for prime time for building web apps?

Is there anyone here that is actually using it successfully in a production environment?

And if so, are there some tricks/suggestions for doing so?

Or should I use Core 2.2? Is that stable enough for production apps?

I know that this is a general question without going specifically into the bugs I've encountered. The bugs are many and variable and the code is too large to summarize here. If no one answers this then that will be my answer. If some people do answer but cannot confirm that they are using it in production then that will be my answer as well. And if some people tell me that I should not be using it right now that will be my answer as well.

In the other case, if people tell me that this is a known problem then perhaps they will be able to point out a workaround. Else I will have to abandon Identity and EF Core and build my own implementations directly. I've been thinking that I should have done this from the beginning, perhaps using Dapper instead of EF Core.

Thanks,

- Grant

HTTP Error 500.19 - Internal Server Error because of changing the URL

$
0
0
I have an ASP.Net application which is working working fine if I have set up the Project URL as: http://localhost:58799/, but I want the project URL to be http://localhost:58799/IMS, it started throwing me error as in the below, how can I fix it? Any help please.
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

Detailed Error Information:
Module	   IIS Web Core
Notification	   BeginRequest
Handler	   Not yet determined
Error Code	   0x800700b7
Config Error	   Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'Windows Login Handler'
Config File	   \\?\C:\GitSrsCodes\IMS\IMS.Web\web.config
Requested URL	   http://localhost:58799/IMS/
Physical Path	   C:\GitSrsCodes\IMS\IMS.Web\
Logon Method	   Not yet determined
Logon User	   Not yet determined
Request Tracing Directory	   C:\Users\aaleem\Documents\IISExpress\TraceLogFiles\IMS.WEB

Config Source:
   72:      <!--register windows login managed handler.-->
   73:       <add name="Windows Login Handler" path="Login" verb="POST" type="IMS.Web.WindowsLoginHandler" preCondition="integratedMode" />
   74:       <!--these handlers resolve .woff not showing problem-->

More Information:
This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error.
If you see the text "There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined", this error is because you are running a .NET Framework 3.5-based application in .NET Framework 4. If you are running WebMatrix, to resolve this problem, go to the Settings node to set the .NET Framework version to ".NET 2". You can also remove the extra sections from the web.config file.

IIS changing the IE11 document mode from 11 (Default) to 7 (Default) when browsing to a site

$
0
0
I have an ASP .NET application that requires Document Mode to default to IE11. I have set the computer local IE11 browser to default to document mode IE11. The problem I have is when I deploy my ASP .NET site to IIS and browse to the site the Document Mode gets changes back to IE7 Default. Because of this my JavaScript does not work. How do I set the IE11 Document mode to IE11 default when I browse to the site and not change it back to IE7 default?

.net core Swagger code gen

$
0
0
Has anyone used Swagger codegen and done customisation on auto generated .net project files
Manoj

The connection was closed unexpectedly for System.Net.HttpWebRequest.GetRequestStream()

$
0
0
Hi all, I need urgent help. I created a web asp.net application (web forms) in c# for an online store integrated with PayPal. I used the code for pdt given at the following link https://github.com/paypal/pdt-code-samples/blob/master/paypal_pdt.cs. Everything worked perfectly during development using sendbox, but on windows server 2016, after the payment on PayPal by redirecting to the page on the site in a protected area, the connection drops and generates an error on the line of code
StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII)
I can't understand what is wrong Confused | :confused:

I have already added the following code,
- on the redirect page-->
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
- on the web.config-->
<binding openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00" />

Also I checked the ssl certificate, that is ok. I updated the framework to the latest version.

On IIS 8 there's this error:

Event code: 3005
Event message: An unhandled exception has occurred.
Event sequence: 22
Event occurrence: 1
Event detail code: 0
Application information:
Trust level: Full
Process information:
Process ID: 6472
Process name: w3wp.exe
Account name: NT AUTHORITY\SYSTEM
Exception information:
Exception type: WebException
Exception message: The underlying connection was closed: The connection was closed unexpectedly.
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at website.ProtectArea.shopping.Page_Load(Object sender, EventArgs e) in C:\xxxx\website\shopping.aspx.cs:line 44
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Request information:
Request URL: https://website.com/ProtectArea/shopping + token info from PayPal
Request path: /ProtectArea//shopping
User host address: xx.xxxx.xxx.xx
User: xxxx@xxxxx.com
Is authenticated: True
Authentication Type: ApplicationCookie
Thread account name: NT AUTHORITY\SYSTEM
Thread information:
Thread ID: 16
Thread account name: NT AUTHORITY\SYSTEM
Is impersonating: False
Viewing all 3938 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>