Subscribe: Web Forms
http://forums.asp.net/rss.aspx?ForumID=18
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
boundfield datafield  data  edit  form  model  new  photo  runat server  runat  server  session  system  text  tostring 
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: Sun, 19 Feb 2017 15:36:48 -0800

 



How can I format the Edit layout of a ASP:DetailsView object.

2017-02-17T20:29:27.14-08:00

As always I really appreciate the great help I get here on this forum.  Your time and advise really helps me.  I do a lot of research before bringing my question here so I do not ask the question lightly.  I am trying to figure out where the formatting is for the EDIT form that is behind the DetailsView Object.  I have been successful in formatting the DetailsView as well as formatting the fields currency and data formats.  The column widths and colors.  However, when I click on the EDIT the DetailsView changes to a gray unformatted object.  I need to be able to format this area also and cannot see where that is being controlled.  Can someone please guide me to that area.  I have included the working code below for my DetailsView.  One note I have Add turned off as I have another part of the program that does that function. 
<[...]



Problem With Access Clint To The Server

2017-02-18T18:33:43.427-08:00

Hi Guys.

I have Problem In My Coding 

I have a page for connecting Finger Print Device From The Asp Page . My Code Works Fine . User Can Connect And Insert Query In Database

But When I Connect From Clint To The Server . I Have some Eror.....

Its . Reasonable Because The Request Process In Server..

What Can I Do ?

Thanks For Reading.. 




connectionString is not considered

2017-02-19T16:15:02.01-08:00

Hello everyone, I'm still in a phase of preparing a website and I am creating the first tables with Entity Framework 6. I'm developing with Visual Stuido 2015 Community in ASP.NET MVC core upgraded to .Net 1.1 Core. The problem origined when I tried to run the command "dotnet ef migrations add FirstMigrations" which continues to report me "Value cannot be null.Parameter name: connectionString", but in reality it is inside both "applicationsettings.json" that the "webconfig". Only when in the instruction "services.AddDbContext (options => options.UseSqlServer ("Server = servername; Database = databasename; Trusted_Connection = True; MultipleActiveResultSets = true "));" I explicitly set the connection string to the command has been successful. Instead with the statement: "services.AddDbContext (options => options .UseSqlServer (config.GetConnectionString (" connectionString "))) this fails. Below the code of the following files: 1.  appsettings.json { "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Debug", "System": "Information", "Microsoft": "Information" } }, "ConnectionStrings": { "connectionStringName": ["Server=servername; Database=databasename; Trusted_Connection=True;", "MultipleActiveResultSets=true"] } } 2. Web.config 3. Startup.cs using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.EntityFrameworkCore; using WebCSI.Models; namespace WebCSI { public class Startup { public IConfigurationRoot config; //public IConfigurationRoot Configuration { get; } public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); config = builder.Build(); } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext(options => options .UseSqlServer("Server=servername; Database=databasename; Trusted_Connection=True;MultipleActiveResultSets=true")); // .UseSqlServer[...]



Check if uploaded IFormFile is a valid image

2017-02-19T20:54:09.737-08:00

Hi,

I'm trying my best to find a solution to this:

I need the controller to check if the uploaded file is a valid image (not just extention or contenttype) I need it to validate that it is an image.

The problem that solutions that I found such as this:

try
{
    using (var bitmap = new System.Drawing.Bitmap(myFile.InputStream))
    {
    }
}
catch (Exception)
{
    return false;
}

are not applicable in Core as Drawing class is not available. 

Thanks a lot




sqldatasource keeps telling me parameter is missing, but it is not.

2017-02-19T22:33:26.233-08:00

I have a sql data source with parameters as follows:


                    
                    
                    
                      
                                        
                

This calls a sql server procedure whose arguments are:

ALTER PROCEDURE [dbo].[GetHighlightAnswersGivenVideoid]
@IDst int,
@videoid int,
@showfirstandlastname bit,
@currentwatcherid int,
@OnlyShowOtherDocsIfHaveto bit

When the page calls it, though, I get the following message:

Database Error: Please wait a few seconds, and try again -- Procedure or function 'GetHighlightAnswersGivenVideoid' expects parameter 
'@OnlyShowOtherDocsIfHaveto', which was not supplied.

I don't understand this.  The parameter is obviously supplied, and I've done a global search through the solution and this is the only call in this page




How to split data when qr code reader device read c#?

2017-02-19T22:31:59.917-08:00

Problem

cannot split data received by reading qr to text boxes when read qr code data ?

Details

I have device reader to qr code i only connect USB to computer then

create text file and open it to receive data and read qr then receive data

to this file and it work success .

I work in windows form application c# visual studio 2015

I need to receive data result from reading qr in windows form directly from

device reader .

I put mouse cursor in text box i receive data below :

30 General Conference of Arab Pharmaceutical Unions UserName : michel bondq Country : Egypt Membership : part

Note : formate above is fixed only variable username,country,Membership

IF i need to read data from device and receive result directly from device

reader in windows form application as following :

textbox1 michel bondq

textbox2 Egypt

textbox3 part

How to separate data to text boxes as above :

meaning i need to split after (:) but i cannot do that

what i try

in textbox4 text changed

string[] sStringResult = textBox4.Text.Split(':');

        textBox1.Text = sStringResult[1].Trim();

        textBox2.Text = sStringResult[2].Trim();

        textBox3.Text = sStringResult[3].Trim();

But it now work so that how to split data ?




How can show confirm message in two cases and don't show confirm in other cases

2017-02-19T21:59:08.467-08:00

when click on button generate row in database and go to next page for summary genaration
But when I generated this row before I want to show confirm message tell me this row generated before
And click ok on confirm message then go to other page for summary generation

Please tell me how to show confirm message in some cases and don't show confirm in other cases?

Thank's for all.



can not use navagation properties in web grid

2017-02-19T21:18:54.017-08:00

i asked this question before but i could not find answer yet.

in web-grid i can not use navigation properties between my classes(products and productimages classes). for example i have used below code in web grid:

 grid.Column("", "test",item=> (item.ProductImages.First().Id)+(item.Price))

but i got error:

'System.Collections.Generic.HashSet' does not contain a definition for 'First'

my total code is like below:

    @model IEnumerable

@using System.Linq;

   @{
    var grid = new WebGrid(source: Model, rowsPerPage: 5,ajaxUpdateContainerId:"divGrid");

}

     @grid.GetHtml(tableStyle: "gridStyle", headerStyle: "gridHeader", rowStyle: "gridRow", alternatingRowStyle: null,htmlAttributes:new{Id="divGrid"},
    columns: new WebGridColumn[] {
   grid.Column("ProductName", "Product Name"),
   grid.Column("Price", "Price"),
   grid.Column("Description", "Description"),
    grid.Column("CategoryName","Category Name",x=>x.Category.CategoryName),

  grid.Column("", "test",item=> (item.ProductImages.First().Id)+(item.Price)),



  grid.Column("","",x=>Html.ActionLink("Edit", "Edit", new{id=x.Id})),
  grid.Column("","",x=>Html.ActionLink("Details", "Details", new{id=x.Id})),
 grid.Column("","",x=>Html.ActionLink("Delete", "Delete", new{id=x.Id}))
}
                    )




Required Field Validator Requires Two Clicks

2017-02-17T17:32:07.397-08:00

Hi,

I am trying to add a required field validator to a textbox in my my ASP.NET C# web forms website.

This is what happens when I enter text into the text-box and click Update:

  1. After I enter text, and click 'Update', the Required Field error message appers, even though there is something in the textbox
  2. Without changing anything in the text-box, I click 'Update' again, and then it submits successfully (i.e. the error does not appear)

Can anyone tell me why this may be occurring?

Here is my ASPX code:




Disable a special feature in V.S.

2017-02-19T19:24:36.833-08:00

I need a brief explanation as to why my code editor keeps showing this feature in my editor window. This feature is preventing me from adding code to my methods. I think the feature is called application insights. Is there a way to set it to disable? Markus.

0 references| 0 requests| 0 exceptions

public ActionResult Create()

{
return View();
}




Display an image to edit View in MVC 5

2017-02-19T20:35:43.913-08:00

Hi, everyone am trying to display an image to the edit view in my web application. But the image comes back broken.  //this is my model for the images using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Web; namespace StoreTypes.Models { public class Photo { [Key] public int ID { get; set; } public string NameofPhoto { get; set; } [ScaffoldColumn(false)] public string ImageName { get; set; } [NotMapped] public HttpPostedFileBase File { get; set; } } } //this is my controller for the images public ActionResult Create() { return View(); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "ID,NameofPhoto,ImageName")] Photo photo, HttpPostedFileBase file) { if (ModelState.IsValid) { try { var filename = ""; if (file != null && file.ContentLength > 0) { Guid gid; gid = Guid.NewGuid(); var extension = Path.GetExtension(file.FileName); filename = gid + extension; var path = Path.Combine(Server.MapPath("~/Content/PhotoGallery/"), filename); var data = new byte[file.ContentLength]; file.InputStream.Read(data, 0, file.ContentLength); using (var sw = new FileStream(path, FileMode.Create)) { sw.Write(data, 0, data.Length); } } photo.ImageName = filename; db.Photos.Add(photo); db.SaveChanges(); } catch (Exception ex) { TempData["Message"] = "
× Directory " + ex.ToString() + " Not found.
"; } return RedirectToAction("Index"); } return View(photo); } public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Photo photo = db.Photos.Find(id); if (photo == null) { return HttpNotFound(); } return View(photo); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult Edit([Bind(Include="ID,NameofPhoto,ImageName")] Photo photo) { if (ModelState.IsValid) { try { db.Entry(photo).State = EntityState.Modified; db.Entry(photo).Property("ImageName").IsModified = false; string path = Server.MapPath("~/Content/PhotoGallery/"); var ImageName = GetImageName(photo.ID); //string Fromfol = GetAlbumNameByPhotoID(photo.ID) + "/" + ImageName; //System.IO.File.Move(path + Fromfol); db.SaveChanges(); } catch (IOException ex) { TempData["Message"] = "
× " + ex.ToString() + "
"; } return RedirectToAction("Index"); } return View(photo); } //my edit view for the image @model StoreTypes.Models.Photo @{ ViewBag.Title = "Edit"; }

Edit

@using (Html.BeginForm("Edit", "Photo", null, FormMethod.Post, new { enctype = "multipart/form-data" })) { @Html.AntiForgeryToken()

Photo


@Html.ValidationSummary(true, "", new { @class = "text-danger" }) @Html.HiddenFor(model => model.ID)
@Html.LabelFor(model => model.NameofPhoto, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EditorFor(model => model.NameofPhoto, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.NameofPhoto, "", new { @class = "text-danger" })



why there is a null reference error in this code

2017-02-17T09:36:28.91-08:00

Hi experts,

I did my debugging at the save event for the 30 labels but I do not understand why there is null reference error in this code

private void UpdateEPMTRequest(string action, string EPMTNumber, int status)
        {
            // 29 labels
            if (HttpContext.Current.Session != null)
            {
                if (status == 0)
                {
                    if (EPMTNumber != null)
                    {
                        eBiz.UpdateEPMTRequest(action, EPMTNumber,
                        Session["SGGID"].ToString(),
                        rbtlistReqType.SelectedItem.Text,
                        Session["IssuerName"].ToString(),
                        Session["DivDescription"].ToString(),
                        Session["SecCode"].ToString(),
                        Session["DepName"].ToString(),
                        Session["Ext"].ToString(),
                        Session["EmpNo"].ToString(),
                        drpCategoryName.SelectedItem.Text,
                        Session["CostCtrCode"].ToString(),
                        lblSubmitDate.Text, lblDueDate.Text,
                        lblRemoveReason.Text, ddlSupplier.SelectedItem.Text,
                        txtSupplierEmail.Text, txtSupplierCttNumber.Text, txtSupplierName.Text, txtSupplierCttPerson.Text,
                       drpMaterialNo.SelectedItem.Text, tbxMaterialName.Text,
                    Session["MANAGERSGGID"].ToString(),
                    Session["Managername"].ToString(),
                    Session["ManagerEmail"].ToString(),
                    Session["DeptHead_NetID"].ToString(), Session["DeptHeadName"].ToString(), Session["DeptHeadEmail"].ToString(), status);
                    }
                }
            }
        }

  So far, when I use

 if (HttpContext.Current.Session != null)
            {
                if (status == 0)
                {
                    if (EPMTNumber != null)

for my mini test - using 4 parameters, the data did get inserted and no such null reference error so I am stumped.

Can someone help me on this ?




How to Add Paging to a HTML Table Populated via Repeater

2017-02-19T18:45:15.777-08:00

Hi, 

I am using a repeater to populate a HTML table below:


">
Name Email Actions
<%#Eval("Name") %> <%#Eval("Email") %>

How do I add paging to this table? (E.g. display 5 records on each page)




receive 0.0 for float type field in controller after perss save button

2017-02-18T12:27:40.043-08:00

Hello. Good time
in view, i have a field of float type. when i entered 2.5 and the press Save button , value of this field in controller is 0.0.
why????
please help me?

 public float Tax { get; set; }


  @Html.TextBoxFor(model => model.Tax)


If the value field entered int (eg 9) is not a problem but the problem is with float(eg 3.5)




How to Dynamically Create Links between Sections on Different Pages using a Repeater

2017-02-19T16:47:09.937-08:00

Hi, I am displaying a number of company logo's on one ASPX page, using a Boostrap Carousel. These images are displayed in the carousel when the image paths are retrieved from an SQL Server database table. Each companies details are displayed on another page also. I would like the carousel to act as a link between these two pages. I would like the carousel to do the following: If the user clicks Company A's logo, they are brought to Company A on the Business.aspx page. If the user clicks Company X's logo, they are brought to Company X on the Business.aspx page. The company details on Business.aspx are displayed using an ASP Repeater and an SQL Server table. How do I connect the  company logo's on Home.aspx to act as links to the company details on Business.aspx? Here is the carousel on Home.aspx: And here are the Company details on Business.aspx:

<%# Eval("Name") %>

<%# Eval("[Desc]") %>


[...]



How to add/remove css class on click of link button

2017-02-19T12:37:39.827-08:00

I need function when ever i call the function it should remove activec lass from Active Customer and assign it to Order.




window.onbeforeunload not working in Chrome

2017-02-19T15:38:46.937-08:00

The below onbeforeunload event works great for IE and FF but for Chrome does not even fire.  I see discussion here about this event to display messages but not much discussion on why Chrome will not invoke this event.  I need this to submit changes to Controller when user requests the next page (in navigation flow).

Thanks if you can advise.

$(function () {   //this is the overall function

window.onbeforeunload = function (e) {
alert("top of onbeforeload");
$("#postForm").submit();

// event.returnValue = false;  //don't return anything, otherwise will have leave this page? confirmation
};

});             //End of overall function




Validations not working

2017-02-19T16:21:52.46-08:00

Hi

 I have below Validations but not working . Even i left fields Blank & click on Save no message is appeared. 




how to disable the records of a gridview row in asp.net c# at page load event ?

2017-02-19T16:02:14.413-08:00

hi everyone !!!!!!! I just want to know that, when i am redirected to exam page , after login, I should see the details of previous exams disabled, indicating that all these papers have been given. How to do that ?



Linq to Sql dynamic

2017-02-17T19:13:14.94-08:00

I have dropdown that will have a text and a value which will be used as the tablename.

How would I do a linq to Sql

string TName = ViewBag.Name;

var get = (from  p in db.[TName]  .Where etc