This is my code for adding gridview with arrows..Gridview is sorting by ascending and descending but i am unable to add arrows.

protected void grdInformation_RowCreated(object sender, GridViewRowEventArgs e)
{
    if (e.Row != null && e.Row.RowType == DataControlRowType.Header)
    {
        foreach (TableCell cell in e.Row.Cells)
        {
            if (cell.HasControls())
            {
                LinkButton button = cell.Controls[0] as LinkButton;
                HtmlGenericControl gv = new HtmlGenericControl("div");

                Label lnkName = new Label();
                lnkName.Text = button.Text;

                if (button != null)
                {
                    Image imageSort = new Image();
                    imageSort.ImageUrl = "~/images/asc.png";

                    if (grdInformation.SortExpression == button.CommandArgument)
                    {
                        if (grdInformation.SortDirection == SortDirection.Ascending)
                        {
                            imageSort.ImageUrl = "~/images/desc.png";
                        }
                        else
                        {
                            imageSort.ImageUrl = "~/images/asc.png";
                        }
                    }

                    gv.Controls.Add(lnkName);
                    gv.Controls.Add(imageSort);
                    button.Controls.Add(gv);
                    }
                }
            }
        }
    }
}}

Dono where i am going wrong , I have took an event for sorting , this is my code for sorting gridview it is working finee, but i am unable to add arrows to the girdview , the above i have tried but its not adding me arrows, how do i add arrows ??

i have tried some articles but i am unable to add arrows with ascending and descending , gridview is sorting when clicking on header rows , but need to display to the user that he can sort based on ascending arrows and descending arrows ...

 protected void grdInformation_Sorting(object sender, GridViewSortEventArgs e)
 {
     if (CurrentSortExpression == e.SortExpression.ToString())
     {
         if (CurrentSortDirection == "asc")
             CurrentSortDirection = "desc";
         else
             CurrentSortDirection = "asc";
     }
     else
     {
         CurrentSortExpression = e.SortExpression.ToString();
         CurrentSortDirection = "asc";
     }

     if (e.SortExpression.Trim() == this.SortField)
     {
         this.sortDirection = (this.sortDirection == "DESC" ? "ASC" : "DESC");
      }
      else
      {
          this.sortDirection = "ASC";
      }

      ViewState["SortDirection"] = this.sortDirection;
      this.SortField = e.SortExpression;

      Bindinfo(GetInformation(ddlStatus.SelectedValue, ddlGroups.SelectedValue));
}

Please help ??

I'm working on an application that will use External Login as only means of user getting on site.

I've successfully implemented the login and modified the ExternalLoginCallback function to simulate a "Normal" Login/Register.

However, the User ClaimsPrincipal for some reason keeps the information it got from External login Info.

And after I register and login, the signed in User has two Identities. The one that was provided by the external login and the one that's provided by the application and the Main identity it uses is the wrong one. I want to get rid of the External ClaimsPrincipal Identity and only keep the one the application created for him.

I don't even know why this happens because inside the function I normally register the user as a "new" ApplicationUser and create an account with a simulated password instead of using the default External Login.

    public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null)
       {
        if (remoteError != null)
        {
            ModelState.AddModelError(string.Empty, $"Error from external provider: {remoteError}");
            return View("Index", "Home");
        }
        var info = await _signInManager.GetExternalLoginInfoAsync();
        if (info == null)
        {
            return RedirectToAction("Index","Home");
        }            

        var name = info.Principal.FindFirstValue(ClaimTypes.GivenName);
        var lastname = info.Principal.FindFirstValue(ClaimTypes.Surname);
        var email = info.Principal.FindFirstValue(ClaimTypes.Email);
        var username = email.Split('@')[0];

        if (email.Split('@')[1] == "tvz.hr")
        {
            var LoginResult = await _signInManager.PasswordSignInAsync(username, "ExternalAccount20$", true, lockoutOnFailure: false);
            if (LoginResult.Succeeded)
            {
                _logger.LogInformation(1, "User logged in.");
                return RedirectToAction("Index", "Home");
            }
            else
            {
                var user = new ApplicationUser { UserName = username, Email = email, GivenName = name, Surname = lastname, Administrator = false };
                var RegisterResult = await _userManager.CreateAsync(user, "ExternalAccount20$");
                if (RegisterResult.Succeeded)
                {
                    await _signInManager.SignInAsync(user, isPersistent: false);
                    _logger.LogInformation(6, "User created an account using {Name} provider.", info.LoginProvider);
                    return RedirectToAction("Index", "Home");
                }
            }
        }

        return RedirectToAction("Index", "Home");
    }

Image of the User that's signed in

From the image I only want to keep the Identity that was Authenticated by the application, not the one from Microsoft.

Worst part, now I can't even use UserManager to get the currently logged in User because User does not match any of the users in the database, I guess because the registered user only has the other ClaimsIdentity.

I'm sure I didn't explain this properly and I'm sorry about that, but I hope that somebody will be able to help me :)

Thank you very much!

I have a DropDownList that didn't work as a DropDownListFor so it has been abandoned.

How do I attach a DropDownList to be the model value for the item in the view. Here is my code.

@model  DirectoryMVC.Models.get_administrators_Result

@{ 
    List<SelectListItem> listItems2 = new List<SelectListItem>();
    listItems2.Add(new SelectListItem { Text = "Mr.", Value = "Mr." });
    listItems2.Add(new SelectListItem { Text = "Ms.", Value = "Ms." });
    listItems2.Add(new SelectListItem { Text = "Dr.", Value = "Dr." });
    listItems2.Add(new SelectListItem { Text = "Miss", Value = "Miss" });
    listItems2.Add(new SelectListItem { Text = "Mrs.", Value = "Mrs." });
    listItems2.Add(new SelectListItem { Text = "Rev.", Value = "Rev." });

    foreach (SelectListItem li2 in listItems2)
    {
        if (li2.Value == this.Model.title)
        {
            li2.Selected = true;
        }
    }

    ViewBag.Titles = listItems2;

    List<SelectListItem> admins = ViewBag.JobTitle;
    foreach (SelectListItem item in admins)
    {
        if (this.Model.admin_code.TrimEnd(' ') == item.Value)
        {
            item.Selected = true;
        }
        else
        {
            item.Selected = false;
        }
    }
    ViewBag.JobTitle = admins;
}
        @Html.HiddenFor(m=>m.admin_id)

        <div class="col-md-1">@Html.DropDownList("Titles")

        </div>
        <div class="col-md-2"> @Html.TextBoxFor(m => m.first_name)
        </div>
        <div class="col-md-2"> @Html.TextBoxFor(m => m.last_name)
        </div>
        <div class="col-md-3"> @Html.DropDownList("JobTitle")
        </div>
        <div class="col-md-3 pull-left"> @Html.TextBoxFor(m => m.email)
        </div>

In the controller, admin_code, and admin_title. The two dropdowns are null. The values are properly selected when looking at the page, but they are not properly mapped to the model on form post.

I recently setup my windows server to run over HTTPS with an SSL certificate.and I have a problem to redirect HTTP request to https I add this code in Global.asax

 protected void Application_BeginRequest()
    {

        if (!Context.Request.IsSecureConnection))
            Response.Redirect(Context.Request.Url.ToString().Replace("http:", "https:"));
    }

but just GET request redirect and POST request failed. please help me.

I have a report, I need to round-off value. if value of field is 1.10 then after round-off it should be 2.00. I have used Round function (round({Table.feild})) but it's using midpoint round off, when value goes greater or equal to 1.5 then it's getting round-off to 2.00. Any help appreciated.

I am doing the tutorial at https://docs.microsoft.com/en-us/aspnet/web-pages/overview/data/5-working-with-data

Code:

@{
var db = Database.Open("SmallBakery");
var selectQueryString = "SELECT * FROM Product ORDER BY Name";
}
<!DOCTYPE html>
<html>
 <head>
   <title>Small Bakery Products</title>
   <style>
   table, th, td {
     border: solid 1px #bbbbbb;
     border-collapse: collapse;
     padding: 2px;
   }
   </style>
 </head>
<body>
<h1>Small Bakery Products</h1>
<table>
   <thead>
       <tr>
           <th>Id</th>
           <th>Product</th>
           <th>Description</th>
   <th>Price</th>
       </tr>
   </thead>
   <tbody>
       @foreach(var row in db.Query(selectQueryString)){
        <tr>
           <td>@row.Id</td>
               <td>@row.Name</td>
               <td>@row.Description</td>
               <td>@row.Price</td>
        </tr>
       }
   </tbody>
  </table>
</body>
</html>

I am always getting an error in the foreach-loop. Why? Can someone help me?

The database is called SmallBakery.mdf and the table is just called Product.

In my _Layout page I have these scripts:

@Scripts.Render("~/Scripts/Scripts.js")
@Scripts.Render("~/Scripts/moment-with-locales.js")
@Scripts.Render("~/Scripts/moment.js")
@Scripts.Render("~/Scripts/bootstrap-datetimepicker.js")
@Scripts.Render("~/Scripts/DayPilot/daypilot-all.min.js")

So instead of writing all of those out, I want to create a bundle:

bundles.Add(new ScriptBundle("~/bundles/otherScripts").Include(
    "~/Scripts/Scripts.js",
    "~/Scripts/moment-with-locales.js",
    "~/Scripts/moment.js",
    "~/Scripts/bootstrap-datetimepicker.js",
    "~/Scripts/DayPilot/daypilot-all.min.js",
    "~/Scripts/DayPilot/daypilot-common.src.js"));

So now in my _Layout page I have this:

@Scripts.Render("~/bundles/otherScripts")

Now in my bootstrap-datetimepicker.js I have edited 1 line.. and the change shows visually when I test this app locally.. but when I publish.. that line that I changed does not work..

The only way it works is if I exclude the bootstrap-datetimepicker.jsfile from the bundle and reference it in the _Layout page specifically.

How do I just combine all of those scripts into the bundle and it work properly when published?

I have a Layout that is calling an static class to retrieve some information from the database, but I'm migrating the project to use entity framework core, but you know that I need to pass an instance parameter to EF Core to instantiate it now, so I have changed the static class to non static but of course now it's complaining because I'm calling that class from the Layout with static signature, and to call it from the Layout I need to pass that instance parameter, so I would need to create a class in the Layout to retrieve it? I don't think I would do that.. What can I do? Any suggestion is welcome.

This is the class(I've changed to an instance class in order to have an instance constructor but now I need to change the signature from the Layout view to call it as an instance class with the instance parameter...):

  public class LocationLookup
    {
       DataContext context;
        public LocationLookup(IOptions<DBConnection> connectionsAccessor)
        {
            context = new DataContext(connectionsAccessor);
        }

        public static List<MyLocations> GetLocations()
        {            
            var locations = context.MyLocations.OrderBy(x => x.Name).ToList();
            return locations;
        }
    }

And this is how I'm currently calling the method(I need to change this to call it as an instance class but how can I retrieve the connectionsAccessor instance parameter? I'm in the Layout.cshtml view)

 @{                                         
      var locations = LocationLookup.GetLocations();
  }

Any suggestion of a better approach is welcome

I get an InvalidOperationException when defining different @model's for _Layout and a different view.

InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'ConsumeWebAPI_Basic.ViewModels.ApiResponse', but this ViewDataDictionary instance requires a model item of type 'ConsumeWebAPI_Basic.ViewModels.MovieSearch'.

_Layout.cshtml

@model ConsumeWebAPI_Basic.ViewModels.MovieSearch

Response.cshtml

@model ConsumeWebAPI_Basic.ViewModels.ApiResponse

I am completely new to this. I read a tutorial about WebPages on https://docs.microsoft.com/de-de/aspnet/web-pages/overview/getting-started/introducing-aspnet-web-pages-2/updating-data.

There, the data is shown as a table. They also added a Edit-Button to each entry. How can I do this with PHP? I've got the table but got no clue how to insert the edit button and link it with a functionality with php.

@grid.GetHtml(
tableStyle: "grid",
headerStyle: "head",
alternatingRowStyle: "alt",
columns: grid.Columns(
    grid.Column(format: @<a href="~/EditMovie?id=@item.ID">Edit</a>),
    grid.Column("Title"),
    grid.Column("Genre"),
    grid.Column("Year")
)
)

Is there a was to set the duration of caching in the web.config for MVC4 .net pages? I have :

[OutputCache(Duration = Convert.ToInt32(ConfigurationManager.AppSettings["cache.eventPage"]), VaryByParam = "Id")]
public ActionResult....

Which will not compile because

An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type

We have very spikey traffic and would like to be able to change this value very quickly with out pushing out a new build. Is this possible?

I've seen this post, but it is not my case cause I run my project from Visual Studio. It is not a deployed application.

I've recently installed Visual Studio 2015 Professional Update 3 and I am running locally ASP.NET Core Web with AngularJS 2 application. What I see is error when I run application is:

HTTP Error 502.5 - Process Failure

Common causes of this issue:

The application process failed to start The application process

started but then stopped The application process started but failed to

listen on the configured port

I've already installed the follwing packages at my PC:

  1. DotNetCore.1.0.0-VS2015Tools.Preview 2
  2. DotNetCore.1.0.1-VS2015Tools.Preview2.0.3
  3. DotNetCore.1.0.4_1.1.1-WindowsHosting
  4. dotnet-dev-win-x64.1.0.1
  5. dotnet-win-x64.1.1.1

Does anybody know how can I resolve this error?

I have created an MVC application that has an aspx page as report view that will render the Crystal report.

I have added a simple Picture and OLE object and set the "Format Object -> Picture -> Graphic Location" as my local physical path. I'm expecting the image to be rendered from the path specified at my Crystal report but the image is not displaying at all. Its throwing error in browser console as

 "xxx/Webform/CrystalImageHandler.aspx?dynamicimage=cr_tmp_image_225a5398-7162-4373-b860-ce62f2c67c24.png"

Based on my reseach I found suggestions to add 2 different handlers for "path=CrystalImageHandler.aspx" in Web.Config file, but it doesn't seems to be work for me.

Any help would be appreciated !

I have the following @Html.DropDownList

   @Html.DropDownList("Key", "-- Select Site --")

And the follow Controller to populate it:

 public ActionResult Index()
        {
            ViewBag.DropDown = new SelectList(DAL.GetClientData(), "WebLink","ResultName", "ID");
            return View();
        }

:

 public IEnumerable<DAL> Get()
    {
        var db = new Conn();
        return db.DALs;
    }

The drop down is populating correctly, but I need to be able to use the information that relates to the selected value from the drop down. For example the drop down shows ResultName name, If I select the 3rd ResultName how do I access its related ID and WebLink.

The reason I need this as when the user selects the result they want I want to navigate to it's related weblink via a submit button something like this:

   public async Task<ActionResult> Go() {
       //Go to results webLink

            return View();
        }

What do I need to change / add to be able to do this?

Hi I was wondering would anyone please be able to help me, I'm creating a travel website in Visual Studio using ASP.NET that generates a unique travel guide for the user using the information they have submitted according to their interests, how their travelling, where their travelling. But I'm unsure how to pull the information from the MySQL table according to what they've input to only show relevant information to them. Could someone please help, i'm not the best at coding and sorry if its really simple.

Thanks

Error: collage is currently unavailable. DotNetNuke.Services.Exceptions.ModuleLoadException: Could not load type 'CollegeApp.Home1'. ---> System.Web.HttpParseException: Could not load type 'CollegeApp.Home1'. ---> System.Web.HttpParseException: Could not load type 'CollegeApp.Home1'. ---> System.Web.HttpException: Could not load type 'CollegeApp.Home1'. at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError) at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData) --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.ProcessException(Exception ex) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) --- End of inner exception stack trace --- at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath) at System.Web.UI.TemplateParser.ParseInternal() at System.Web.UI.TemplateParser.Parse() at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType() at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at DotNetNuke.UI.ControlUtilities.LoadControl[T](TemplateControl containerControl, String ControlSrc) at DotNetNuke.UI.Modules.WebFormsModuleControlFactory.CreateModuleControl(TemplateControl containerControl, ModuleInfo moduleConfiguration) at DotNetNuke.UI.Modules.ModuleControlFactory.LoadModuleControl(TemplateControl containerControl, ModuleInfo moduleConfiguration) at DotNetNuke.UI.Modules.ModuleHost.LoadModuleControl() --- End of inner exception stack trace ---

I'm trying to get a value from my database but it keeps returning a value of 0 and i cannot figure out why. I've been retrieving data from the database for the whole of my project and it is just not working here. None of the values in the database are = to 0.

int rentalPrice is the one being returned as 0`

    protected void Page_Load(object sender, EventArgs e)
    {
       if (Request.QueryString["id"] == null) 
       {
           Response.Redirect("DisplayCars.aspx");
       }
       else
       {
           id = Convert.ToInt32(Request.QueryString["id"].ToString());
           con.Open();
           SqlCommand cmd = con.CreateCommand();
           cmd.CommandType = CommandType.Text;
           cmd.CommandText = "select * from cars where id ='" + id + "'";
           cmd.ExecuteNonQuery();
           lblCarID.Text = id.ToString();
           DataTable dt2 = new DataTable();
           SqlDataAdapter da2 = new SqlDataAdapter(cmd);
           foreach (DataRow dr2 in dt2.Rows)
           {
               rentalPrice = Convert.ToInt32(dr2["car_rental_price"]);
           }
           lblRentalPrice.Text = rentalPrice.ToString();

           con.Close();
       }

am trying to pass two DateTime, and a Bool from a checkbox to my controller

Controller action:

[HttpPost]
    public ActionResult TestParse(DateTime DateFrom, DateTime DateTo, bool active)

here is my razor view:

    @using (Html.BeginForm("TestParse", "Sags", FormMethod.Post))
{
    <input type="checkbox" name="active">
    <input type="date" name="DateFrom">
    <input type="date" name="DateTo">
    <input type="submit" value="Submit">
}

it finds the controller, but it doesn't pass the values, they're all null execpt for active which is "true" how can i get the values of these?

I am loading URDU text from database and trying to download it in PDF/Word but it doesn't work and give me blank page but for ENGLISH it works fine.

Why doesn't it work for non-english language i.e. as urdu. I am using iText and tried other 3rd party also but not working.

Urdu text loaded from Database column which nvarchar:

<p>
    1. <span dir="RTL">میں اس ادارے کی پالیسیوں کی خلاف ورزی نہیں کرے گا</span>.</p>
<p>
    2. <span dir="RTL">میرے فرائض نشان تک ہو گا</span>.</p>
<p>
    3. <span dir="RTL">کوئی خلاف ورزی ادنڈت جانا چاہیئے</span></p>
<p>
    4. <span dir="RTL">میں نے اپنے ملک کے لئے اپنی جان دیتا ہوں گے</span>.</p>
<p>
    5. <span dir="RTL">میں ایک غیر معمولی انداز میں رد عمل کا اظہار تو میری زبان معاف کرنا</span>.</p>
<p>
    6. <span dir="RTL">میں ایسا میرا سب کچھ میرا ادارے اور ملک کی خاطر ہے</span>.</p>
<p>
    7. <span dir="RTL">پاکستان ایک خود مختار ملک ہے اور رہے گی</span>.</p>
<p>
    8. <span dir="RTL">میں مکمل اپنے فرائض کو بھر دوں گا</span></p>
<p>
    9. <span dir="RTL">میں پکڑے گئے تو؛ میں نے آپ کو نہیں پتہ</span>.</p>
<p>
    10. <span dir="RTL">تمام ہے</span>.</p>

Code

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {

                Int64 AppliedWorkID= SharedUtility.DecryptURL(Request.QueryString["AppliedWorkID"].ToString()).ToInt64();

                System.Data.DataTable dt = ClsTender.GetRandomData(AppliedWorkID);

                string Description = dt.Rows[0]["Description"].ToString();

                Download(Server.HtmlDecode(Description));
            }
            catch (Exception ex)
            {


            }
        }

    }

 private MemoryStream Export(string html)
    {


        MemoryStream msOutput = new MemoryStream();
        TextReader reader = new StringReader(html);

        // step 1: creation of a document-object
        Document document = new Document(PageSize.A4, 30, 30, 30, 30);


        // step 2:
        // we create a writer that listens to the document
        // and directs a XML-stream to a file
        PdfWriter writer = PdfWriter.GetInstance(document, msOutput);

        // step 3: we create a worker parse the document
        HTMLWorker worker = new HTMLWorker(document);

        // step 4: we open document and start the worker on the document
        document.Open();
        worker.StartDocument();

        // step 5: parse the html into the document
        worker.Parse(reader);

        // step 6: close the document and the worker
        worker.EndDocument();
        worker.Close();
        document.Close();


        return msOutput;
    }

    public void Download(string html)
    {

            try
            {
                MemoryStream memStream = Export(html); // returns a memory stream object
                byte[] bytesInStream = memStream.ToArray();
                Response.Clear();

                string FileName = "TestPDF.pdf";
                FileName = FileName.Replace(",", "");

                Response.ContentType = "application/pdf";
                Response.Headers.Remove("content-disposition");
                Response.AddHeader("content-disposition", "attachment; filename=\"" + FileName + "\"");

                Response.BinaryWrite(bytesInStream);
                Response.End();
                Response.Flush();

            }
            catch (Exception)
            {


            }

            //Page.ClientScript.RegisterStartupScript(this.GetType(), "Print", "javascript:window.print();", true);
    }

I'm working on shopping cart application where I have listed all the products in a ListView. Then on button click of each product the image slider changes. Now I want to make it on mouseover instead of click. Below is the code I have tried to achieve.

ASP

 <div class="col-md-12 ">
                <div class="col-md-4 single_left pull-left">
                    <div class="flexslider">
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <asp:Repeater runat="server" ID="Repeater">
                                    <HeaderTemplate>
                                        <ul class="slides">
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <li data-thumb='<%# "assets/products/"+DataBinder.Eval(Container.DataItem, "Image1") %>'>
                                            <asp:Image ID="image5" runat="server"
                                                ImageUrl='<%# "assets/products/"+DataBinder.Eval(Container.DataItem, "Image1") %>' />
                                        </li>
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        </ul>
                                    </FooterTemplate>
                                </asp:Repeater>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>
                    <script defer src="assets/js/jquery.flexslider.js"></script>
                    <link rel="stylesheet" href="assets/css/flexslider.css" type="text/css" media="screen" />
                    <!-- FlexSlider -->
                    <div class="caption">
                        <strong>
                            <asp:Label ID="lblPrice" runat="server" Text="*"></asp:Label></strong>
                        <strong>
                            <asp:Label ID="ItemCode" runat="server" Text="*"></asp:Label></strong>
                        <p>
                            <small><strong>
                                <asp:Label ID="lblDesc" runat="server" Text="*"></asp:Label>
                            </strong></small>
                            <br />
                            <asp:Label ID="lblID" Style="display: none;" runat="server" Text='<%# Eval("ID")  %>'></asp:Label>
                            <small>
                                <asp:Label ID="lblMsg" runat="server" Text="*" ForeColor="#990000"></asp:Label>
                            </small>
                            <br />
                        </p>
                        <asp:TextBox ID="txtqty" type="number" class="form-control" Text="0" runat="server"></asp:TextBox>
                    </div>
                    <asp:LinkButton ID="btnSubmit" type="submit" CssClass="add-cart item_add" runat="server" OnClick="btnSubmit_Click"><i class="fa fa-save"></i> Add to Cart</asp:LinkButton>
                    <script>
                        // Can also be used with $(document).ready()
                        $(window).load(function () {
                            $('.flexslider').flexslider({
                                animation: "slide",
                                controlNav: "thumbnails"
                            });
                        });
                    </script>
                </div>
                <div class="col-md-8 single-top-in simpleCart_shelfItem">
                    <asp:ListView ID="ImagesList" runat="server"
                        DataKeyNames="ID"
                        GroupItemCount="15"
                        OnPagePropertiesChanging="ImagesList_PagePropertiesChanging" OnSelectedIndexChanged="OnSelectedIndexChanged">
                        <EmptyDataTemplate>
                            No Images found.
                        </EmptyDataTemplate>
                        <LayoutTemplate>
                            <table>
                                <tr runat="server" id="groupPlaceholder" />
                            </table>
                        </LayoutTemplate>
                        <GroupTemplate>
                            <tr>
                                <td runat="server" id="itemPlaceholder" />
                            </tr>
                        </GroupTemplate>
                        <ItemTemplate>
                            <td>
                                <asp:LinkButton ID="LBtn" runat="server"
                                    CommandName="Change"
                                    OnCommand="btnDetails_Command"
                                    CommandArgument='<%# Eval("Notes") %>'>
                                   <img src='<%#"assets/products/"+Eval("ImageUrl").ToString() %>' class="image" style="Width:50px;Height:50px" alt="Change" onmouseover="this.OnCommand"  />
                                </asp:LinkButton>
                            </td>
                        </ItemTemplate>
                    </asp:ListView>
                </div>
                <div class="clearfix"></div>
                <!---->
            </div>

I'm creating a barcode using ASP.Net MVC The problem is it's working with links. But it needs to work with form values.

This is my controller :

[HttpPost]
    public ActionResult Barcode(BarcodeModel B)
    {
        string BarcodeTitle = B.BarkodTitle;
        string BarcodeNumber = B.BarcodeNumber;

        Codec objbar = new Codec();

        Byte[] BarcodeImage = objbar.getBarcodeImage(BarcodeNumber, BarcodeTitle);

        Stream Memory = new MemoryStream(BarcodeImage);

        Memory.Position = 0;

        var Result = new FileStreamResult(Memory, "image/png");
        Result.FileDownloadName = String.Format("{0}.png", BarcodeTitle);

        return Result ;
    }

This is my JavaScript code :

 <script type="text/javascript">

    function BarkodKaydet()
    {
        var BarkodModel = new Object();

        BarkodModel.DeweyCode = document.getElementById('DeweyCode').value;
        BarkodModel.CutterNumber = document.getElementById('CutterNumber').value;
        BarkodModel.Year = document.getElementById('Year').value;
        BarkodModel.Bind = document.getElementById('Bind').value;
        BarkodModel.Copy = document.getElementById('Copy').value;
        BarkodModel.BarcodeTitle = document.getElementById('BarcodeTitle').value;
        BarkodModel.BarcodeNumber = document.getElementById('BarcodeNumber').value;

        $.ajax({
            type: "post",
            url: "@Url.Action("Barcode")",
            dataType : "json",
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(BarkodModel),
            success: function (data) { console.log(data); },
            failure: function (errMsg) {
                alert(errMsg);
            }
        });
    }

</script>

But it's not working.

It' just working with link how I'm changing controller to ;

public ActionResult Barcode(string barcodeNumber, string barcodeText)
{
    Codec objbar = new Codec();

    Byte[] BarkodImage = objbar.getBarcodeImage(barcodeNumber, barcodeTitle);

    Stream Memory = new MemoryStream(BarcodeImage);

    Memory.Position = 0;

    var Result = new FileStreamResult(Memory, "image/png");
    Result.FileDownloadName = String.Format("{0}.png", BarcodeTitle);

    return Result ;
}

this and change view to ;

<img src="/Home/BarcodeImage?barcodeText=Can&barcodeNo=12345" />

to this.

When the page opening, the linked image sending values to controller and showing barcode to me.

But I need;

When the form values submitting to model, ActionResult needs to create barcode from model, refresh the same page and It will show only barcodeImage to me.

How can I configure it ?

Best regards.