I've been asked to migrate a web application from Server 2003 (IIS 6.0) to Server 2012 R2 (IIS 8.5).

I have some old source code but I'm not sure whether it matches what's currently deployed, so I'm trying to just move the deployed files from one server to another.

It kind of works, but there's an issue with trailing slashes and default documents I could use some help with.

It's a .NET 4.0 web forms application, forms authentication, but with some MVC thrown in for good measure!

On the current server, Fiddler reveals the following behaviour

However, on the new server, it's different

I'm at loss to work out how to fix things on the new server. I'm reluctant to change code and re-deploy as this will open a whole new can of worms I'm sure.

Help appreciated. Thanks.

Doug

In one of project i saw the below code.

        string FileName = Request.QueryString["filename"];
        System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
        response.ClearContent();
        response.Clear();
        response.ContentType = "application/octet-stream";
        response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";");
        response.TransmitFile(Server.MapPath("~/" + FileName));
        response.Flush();
        response.End();

which is used to download file from server. Now if someone changes filename (like web.config) in query string manually then it downloads config file also.

So please share your knowledge how to restrict from download based on file extension.

I have a website that is made for desktops, that uses the Bootstrap 3 framework. So far everything good, in my razor views I have intellisense for the many different Bootstrap classes which is nice to have.

But now I am adding a new area for a mobile version of the website, which will be powered by jQuery Mobile. Here I also get the css classes to pop up with intellisense, but I also see all the bootstrap classes, because those css files are used for the other views.

Question:

Is there a way to temporarily disable the Bootstrap files from showing up in Intellisense while working on the mobile section?


Also, a little unrelated, but jQuery mobiles makes extensive use of data-* attributes, is there perhaps an easy way to get those in intellisense too (maybe by defining them myself in a file or something?).

Thanks in advance!

I want to use @Html.TextArea() instead of @Html.EditorFor() but I am getting this error

cannot convert lambda expression to type 'string' because it is not a delegate type.

Model

public class ProductFeature
{
    [Required(ErrorMessage = "{0} boş geçilemez")]
    [DisplayName("Ürün Özellik Adı")]
    public string ProductFeatureName { get; set; }

    [Required(ErrorMessage = "{0} boş geçilemez")]
    [DisplayName("Ürün Özellik Değeri")]
    public string ProductFeatureValue { get; set; }

    ....
}

View

// Works
@Html.EditorFor(model => model.ProductFeatureName, new { htmlAttributes = new { @class = "form-control" } })

// Throws error
@Html.TextArea(model => model.ProductFeatureName, new { htmlAttributes = new { @class = "form-control" } })

Is it possible to write jQuery code inside razor Html.Raw() method. I have a model, who has a property named body. body is a html string. I use Html.Raw(model.body) to render html in the page. Is it possible to include jquery code in the string, to control the ids and classes in the html string of body.

I tried using inline <script></script> tag but it didn't work.

<table>
    @foreach(var items in Model)
    {
        <tr>
            <td>@items.name</td>
            <td>@items.designation</td>
            <td>@items.salary</td>
        </tr>
    }
</table>

The code works fine when written directly on cshtml page.

If I use @Html.Raw(items.data) it shows the code instead of data/Values.

My requirement is to store the above code in database and display records stored in database and process it at runtime. I want to fetch data by the code.

I want to store the compiled templates into MemoryCache. I read that i have to store the IRazorEngineService instance. Does it check again if the file has been altered if i execute RunCompile again? Or how could i delete the key from the cache if i have to implement the check myself?

In my templates I've got these repeating blocks of content which I want to abstract to a single component:

<header class="Component-header">
  <!-- Some content here is always the same -->
  <!-- And some content is different for each use -->
</header>
<div class="Component-body">
  <!-- Some content here is always the same -->
  <!-- And some content is different for each use -->
</div>
<footer class="Component-footer">
  <!-- Some content here is always the same -->
  <!-- And some content is different for each use -->
</footer>

Normally I would use a razor partial view for this, and pass it some variables. However in this case that would mean passing big chunks of html as variables, which doesn't seem wise.

I've found this article: http://www.growingwiththeweb.com/2012/09/custom-helper-for-surrounding-block-in.html, which explains how to create block helpers. It's a little closer to what I'm trying to do, but it still requires me to define the html as a string, which is not what I want (as the amount of html is sizeable enough for it to become unmaintainable).

From what I understand I can't use layouts for this either, because the components occur multiple times on one page. So my question is: how can I abstract the pattern above to a single reusable component, which I can reuse on a page, which accepts multiple areas of html and accepts variables?

I am new to asp.net, I have a task to implement forgot password in asp.net C#. When user registers himself, he provides the answer of secret question in text box. At some times, if the user forgets his password, he clicks on forget password link and then enters his username, then he is asked the secret question, if answer matches, then password is sent to user. I have seen some of the videos and surfed through the internet but could not find any suitable solution. Please guide me how can I do that?

linq convert into sqlquery get value where clause context.purposes.tolist (id =4000 into 4050) how it is ???????

      public ActionResult Index()
    {
        PurposeModel model = new PurposeModel();
        using (DAL.db_Hajj_UmrahEntities context = new DAL.db_Hajj_UmrahEntities())
        {
            List<DAL.Purpose> purposelist = context.Purposes.ToList();
            model.PurposeList = purposelist.Select(x => new SelectListItem()
                {
                    Text =x.PurPose1,
                    Value=x.Id.ToString()
                });

        }
        return View(model);
    }

Onclientclick is not working for me in asp button. The button is present inside update panel

    <asp:UpdatePanel ID="UpLoad" runat="server">
<ContentTemplate>
     <asp:Button ID="btnProcess" runat="server" Text="Process" OnClientClick="alert('hi');" onClick="btnProcessing_Click" />
</ContentTemplate>
<Triggers>
    <asp:PostBackTrigger ControlID="btnProcess" />
</Triggers>

Can someone help me where am i going wrong.

I have a tab in a page in each tab i have three link buttons on each click in repeater data have to be updated and focus on particular link and tab. Foe example on tab events and in that tab i clicked on immigration then data should be populated and get focus on events tab and immigration link button (selected).

Html Page :

<ul class="nav nav-tabs">
                            <li class="active" runat="server" id="news_tab"><a href="#tab" data-toggle="tab">News</a></li>
                            <li runat="server" id="events_tab"><a href="#tab2" data-toggle="tab">Events</a></li>


                          </ul>

<div class="tab-content tabbed_widget clearfix" style="background-color:none;">
                            <div class="tab-pane active" id="tab" style="background-color:none;" runat="server">

                              <ul class="list quicker">
                                <li runat="server"><asp:LinkButton runat="server" ID="education_news" OnClick="education_news_Click" >Education</asp:LinkButton></li>
                              <li runat="server"><asp:LinkButton runat="server" ID="immigration_news" OnClick="immigration_news_Click">Immigration</asp:LinkButton></li>
                                <li runat="server"><asp:LinkButton runat="server" ID="visa_news" OnClick="visa_news_Click" >Visa</asp:LinkButton></li>

                            </ul>

                            </div><!-- tab pane-->

                            <div class="tab-pane" id="tab2" runat="server">
                                <ul class="list quicker">
                                <li runat="server"><asp:LinkButton runat="server" ID="education_events" OnClick="education_events_Click" >Education</asp:LinkButton></li>
                              <li runat="server"><asp:LinkButton runat="server" ID="immigration_events"  OnClick="immigration_events_Click">Immigration</asp:LinkButton></li>
                                <li runat="server"><asp:LinkButton runat="server" ID="visa_events" OnClick="visa_events_Click" >Visa</asp:LinkButton></li>

                            </ul>
                            </div><!-- tab pane -->




                            </div>

Code behind :

 protected void education_news_Click(object sender, EventArgs e)
    {
        string edu = education_news.Text;

        using (SqlConnection _con = new SqlConnection(_Data.CS))
        {
            SqlCommand _Cmd = new SqlCommand("select * from tbl_news where type=@type and category=@cat", _con);
            _Cmd.Parameters.AddWithValue("@type", edu);
            _Cmd.Parameters.AddWithValue("@cat", newscat);
            _con.Open();
            dl_news.DataSource = _Cmd.ExecuteReader();
            dl_news.DataBind();
            ((HtmlGenericControl)education_news.Parent).Attributes["class"] = "liactive";
            ((HtmlGenericControl)immigration_news.Parent).Attributes["class"] = "NA";
            ((HtmlGenericControl)visa_news.Parent).Attributes["class"] = "NA";
            ((HtmlGenericControl)education_events.Parent).Attributes["class"] = "NA";
            ((HtmlGenericControl)immigration_events.Parent).Attributes["class"] = "NA";
            ((HtmlGenericControl)visa_events.Parent).Attributes["class"] = "NA";
            tab.Attributes.Add("class", tab2.Attributes["class"] + " active");
            tab2.Attributes.Add("class", tab.Attributes["class"].Replace("active", "")); 
        }

    }

I use a MVC.JQuery.Datatables in my ASP.NET MVC5 webapplication. I want to bind a select-list to the Datatable as a filter select, like the Position select in this example.

In my partial view, I have used following inline code:

@using Mvc.JQuery.DataTables
@using Web.Controllers
@model Web.Models.Material.MaterialViewModel
@{
    var vm = Html.DataTableVm("MaterialListNotDeptRecvTbl",
             (MaterialController ctrl) => ctrl.GetMaterialNotReceivedUser(null));
    vm.StateSave = true;
    vm.ColumnFilter = true;
    vm.FilterOn("SellerId", new {sSelector = "#sellerSelect" }, new {sSearch = "All"}).Select(Model.Users.Select(x=> x.Value).ToArray());
}

@Html.Partial("DataTable", vm)

My MVC-controller looks like this:

public DataTablesResult<SalesLineDtModel> GetMaterialNotReceivedUser(DataTablesParam dataTablesParam)
{
     return GetSaleLines(dataTablesParam, SalesLineType.User,true);
}

My select-box looks like this:

<select id="sellerSelect" class="control">
@foreach (var selectedUser in Model.Users)
{
    <option value="@selectedUser.Value">@selectedUser.Text</option>
}
</select>

I have tried to catch the select-event in my Site.js - but can't figure out to call the webservice (GetMaterialNotReceivedUser).

In the example, included in the download-package from the github-page, it seems the postback is included in the Datatables api.

Do I have to modifify or add some functions in the jquery.dataTables.columnFilter.js?

I have a query, hope you guys will be able help me out in resolving this issue. Question: Remove unwanted Quotes " from the CSV file .

Records in the File

Row1:  "qwerty","123456","AMY Chiappa","20160425"
Row2:  "asdf","65436","Vishwa Prasad","20160425"
Row3:  "lkjhg","34567",**"Pavan "Kumar" Kotari"**,"20160425"
Row4:  "xcvbn","0987766","Mandar DIWAN","20160425"

from the above input i have to remove Extra Quotes present in Row 3 (Pavan "Kumar" Kotari). The out put should look as shown below

Row1:  "qwerty","123456","AMY Chiappa","20160425">
Row2:  "asdf","65436","Vishwa Prasad","20160425"
Row3:  "lkjhg","34567",**"Pavan Kumar Kotari"**,"20160425"
Row4:  "xcvbn","0987766","Mandar DIWAN","20160425"

Thanks for your ideas in advance. Cheers Dev!!!

I am new to Ajax and Jquery.I have a form where there is a DepositAccountNumberId text box and its value is stored in a Hidden Field for Validation.

OnBlur event of DepositAccountNumberId TextBox should give a bootbox alert ("This Account Number has been Suspended"). I have posted the code below:

Javascript Function to CheckAccountSuspension()

var exist = true;

        function checkAccountSuspension() {
            var accountNumberId = $('#DepositAccountNumberIdHiddenField').val();

          //  alert(accountNumberId);
            if (accountNumberId == "") {
                //
            } else {
                try {
                    var url = '/WebMethods/AccountDetails.asmx/IsAccountSuspended';
                   
                    var d = { accountNumberId: accountNumberId };
                    var jqXhr = ajaxPost(url, d, true);
                    jqXhr.done(function(data) {

                        if (data) {
                            var ret = data.d;
                            if (ret) {
                                $('#DepositAccountNumberIdHiddenField').val(accountNumberId);
                                exist = true;
                            } else {
                                $('#DepositAccountNumberIdHiddenField').val('');
                                bootbox.alert("This Account Has been Suspended");
                                exist = false;
                            }
                        }

                    }).fail(function() {
                        $('#DepositAccountNumberIdHiddenField').val('');
                    });


                } catch (e) {
                    bootbox.alert('Error: ' + e);
                }
            }




  $('#DepositAccountNumberTextBox').on('blur', function () {
                checkAccountSuspension();
            });

Web Method

  [WebMethod(EnableSession = true)]
    public bool IsAccountSuspended(string accountNumberId)
    {
        int officeId = OfficeId;
        return BusinessLayer.Transactions.Transactions.IsAccountSuspended(officeId, accountNumberId.ToLong());
    }

IsAccountSuspended in Business Layer

public static bool IsAccountSuspended(int officeId, long accountNumberId)
    {
        if (accountNumberId <= 0)
        {
            return false;
        }
        return DatabaseLayer.Transactions.Transactions.IsAccountSuspended(officeId,accountNumberId);
    }

IsAccountSuspended in Database Layer

public static bool IsAccountSuspended(int officeId, long accountNumberId)
    {

        if (accountNumberId <= 0)
        {
            return false;
        }

        var sql = "SELECT * FROM deposit.is_suspended(@AccountNumberId::bigint);";
        using (var command = new NpgsqlCommand(sql))
        {
            command.Parameters.AddWithValue("@AccountNumberId", accountNumberId);
            using (var table = DBOperations.GetDataTable(command))
            {
                if (table.Rows.Count >= 1)
                {
                    return true;
                }
                return false;
            }
        }


    }

The Validation doesnot work.The ajax isnot called to check if the account is suspended.Help Please.

I have a page that runs reports on sales for a time period. When I run it for a month with around 88 transactions, its take a while but I can live with it for now. Problem is when I try run the page for a year or over 3 months, its takes around 30minutes then goes to an error page saying "The cms.kics.com.au isnt working.. It didnt send any data...err_empty_response". ] First thing comes to mind is there is too much data to return and its timing out on the request. I have increased the execution time in the web.config and also the page timeout but no luck.

<httpRuntime maxRequestLength="409600" executionTimeout="720" />

Page.Server.ScriptTimeout = 3600;

I also tried flushing the data each time it goes in the repeater but doesn't do anything.

The code behide calculates the totals for the data range works fine but when it populates the salesrepeater with all the products that was sold, I get a timeout.

Is there a way to resolve this? I was thinking maybe a stored procedure to run in the background that calculates the total for all products and on the repeater, just to output each item. sales by 3 months can go up to 300-400.

Please see below code.

  protected void BtnFilter_Click(object sender, EventArgs e)
{
    if (StartDate.SelectedDate == null && FinishDate.SelectedDate == null)
        return;

    startDate = DateTime.Parse(StartDate.SelectedDate.ToString()).Date;
    endDate = DateTime.Parse(FinishDate.SelectedDate.ToString()).Date;

    DateTime now = DAL.TimeZoneConversion.ConvertDateTime(DateTime.UtcNow, thisShop.Company.TimeZoneLocationID);

    CurrentDateTimeLiteral.Text = now.ToString() + " (" + thisShop.Company.TimeZoneLocationID + ")";
    DateRangeLiteral.Text = startDate.ToShortDateString() + " - " + endDate.ToShortDateString();
    TaxTypeLiteral.Text = thisShop.TaxName;
    TaxTypeLiteral2.Text = thisShop.TaxName;
    TaxTypeLiteral3.Text = thisShop.TaxName;
    TaxTypeLiteral4.Text = thisShop.TaxName;
    TaxTypeLiteral5.Text = thisShop.TaxName;
    TaxTypeLiteral6.Text = thisShop.TaxName;
    TaxTypeLiteral7.Text = thisShop.TaxName;
    TaxTypeLiteral8.Text = thisShop.TaxName;
    TaxTypeLiteral9.Text = thisShop.TaxName;

    IObjectScope scope = ORM.ScopeFactory.GetPerRequestScope(HttpContext.Current);

    decimal totalPAmount = 0;
    decimal totalPTax = 0;
    decimal totalDAmount = 0;
    decimal totalDTax = 0;
    decimal totalAmount = 0;
    decimal totalTax = 0;

    var shopOrders = (from shopOrder in scope.Extent<ORM.Shoporder>()
                      where shopOrder.ShopId == shopId &&
                            shopOrder.CreateDateTime.Date >= startDate && shopOrder.CreateDateTime.Date <= endDate && shopOrder.IsDeleted == false &&
                            (shopOrder.IsReceiptSent == true || shopOrder.IsReceiptSkipped == true)
                      orderby shopOrder.CreateDateTime descending
                      select shopOrder);

    foreach (ORM.Shoporder thisShopOrder in shopOrders.ToList())
    {
        decimal orderTotal = thisShopOrder.TotalCostIncludingTax; //DAL.DataClasses.ShopOrder.CalculateOrderTotal(thisShopOrder.ShopOrderId);

        totalAmount += thisShopOrder.TotalCostIncludingTax;
        totalTax += thisShopOrder.TotalTaxCost;
        totalPAmount += thisShopOrder.ProductCostIncludingTax;
        totalPTax += thisShopOrder.ProductTaxCost;
        totalDAmount += thisShopOrder.DeliveryCostIncludingTax;
        totalDTax += thisShopOrder.DeliveryTaxCost;

    }

    TotalLiteral.Text = totalAmount.ToString("C");
    TotalTaxLiteral.Text = totalTax.ToString("C");
    TotalDLiteral.Text = totalDAmount.ToString("C");
    TotalDTaxLiteral.Text = totalDTax.ToString("C");
    TotalPLiteral.Text = totalPAmount.ToString("C");
    TotalPTaxLiteral.Text = totalPTax.ToString("C");

    ReportDiv.Visible = true;
    Populate();
}


private void Populate()
{
    IObjectScope scope = ORM.ScopeFactory.GetPerRequestScope(HttpContext.Current);

    var result = from o in scope.Extent<ORM.Shopproductvariationprice>()
                 where o.Shopproduct.Shopcategory.ShopId == shopId
                 orderby o.Name, o.PriceIncludingTax
                 select o;

    SaleRepeater.DataSource = result.ToList();
    SaleRepeater.DataBind();
}

protected void SaleRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
    IObjectScope scope = ORM.ScopeFactory.GetPerRequestScope(HttpContext.Current);

    RepeaterItem item = e.Item;
    if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
    {
        ORM.Shopproductvariationprice thisPrice = (ORM.Shopproductvariationprice)item.DataItem;

        Literal ProductNameLiteral = (Literal)item.FindControl("ProductNameLiteral");
        Literal ProductCountLiteral = (Literal)item.FindControl("ProductCountLiteral");
        Literal ProductAmountIncludingTaxLiteral = (Literal)item.FindControl("ProductAmountIncludingTaxLiteral");
        Literal ProductAmountExcludingTaxLiteral = (Literal)item.FindControl("ProductAmountExcludingTaxLiteral");
        Literal ProductTaxLiteral = (Literal)item.FindControl("ProductTaxLiteral");

        int productCount = 0;
        decimal productAmount = 0;
        decimal productTax = 0;

        ProductNameLiteral.Text = thisPrice.Name;

        var shopOrders = (from shopOrder in scope.Extent<ORM.Shoporder>()
                          where shopOrder.ShopId == shopId &&
                                shopOrder.CreateDateTime.Date >= startDate && shopOrder.CreateDateTime.Date <= endDate && shopOrder.IsDeleted == false &&
                                (shopOrder.IsReceiptSent == true || shopOrder.IsReceiptSkipped == true)
                          orderby shopOrder.CreateDateTime descending
                          select shopOrder);

        foreach (ORM.Shoporder thisShopOrder in shopOrders.ToList())
        {
            foreach (ORM.Shoporderproduct thisShopOrderProduct in DAL.DataClasses.ShopOrder.GetProductsInOrder(thisShopOrder.ShopOrderId))
            {
                if (thisShopOrderProduct.ShopProductVariationPriceId == thisPrice.ShopProductVariationPriceId)
                {
                    productCount += thisShopOrderProduct.Quantity;
                    productAmount += (thisShopOrderProduct.Quantity * thisShopOrderProduct.Shopproductvariationprice.PriceIncludingTax);

                    if (thisShopOrderProduct.Shopproductvariationprice.Shopproduct.IsTaxable)
                    {
                        decimal taxRate = 100 + thisShop.TaxPercent;
                        decimal thisProductPriceExcludingTax = thisShopOrderProduct.Shopproductvariationprice.PriceIncludingTax * 100;
                        thisProductPriceExcludingTax = thisProductPriceExcludingTax / taxRate;
                        decimal thisProductTax = thisShopOrderProduct.Shopproductvariationprice.PriceIncludingTax - thisProductPriceExcludingTax;

                        productTax += (thisShopOrderProduct.Quantity * thisProductTax);
                    }
                }
            }
        }

        ProductCountLiteral.Text = productCount.ToString();
        ProductAmountIncludingTaxLiteral.Text = productAmount.ToString("C");
        ProductAmountExcludingTaxLiteral.Text = (productAmount - productTax).ToString("C");
        ProductTaxLiteral.Text = productTax.ToString("C");

        totalProductAmount += productAmount;
        totalProductTax += productTax;
        totalItemsSold += productCount;

        Response.Flush();

    }

    if (item.ItemType == ListItemType.Footer)
    {
        Literal TotalCountLiteral = (Literal)item.FindControl("TotalCountLiteral");
        Literal TotalAmountIncludingTaxLiteral = (Literal)item.FindControl("TotalAmountIncludingTaxLiteral");
        Literal TotalAmountExcludingTaxLiteral = (Literal)item.FindControl("TotalAmountExcludingTaxLiteral");
        Literal TotalTaxLiteral = (Literal)item.FindControl("TotalTaxLiteral");

        TotalCountLiteral.Text = totalItemsSold.ToString();
        TotalAmountIncludingTaxLiteral.Text = totalProductAmount.ToString("C");
        TotalAmountExcludingTaxLiteral.Text = (totalProductAmount - totalProductTax).ToString("C");
        TotalTaxLiteral.Text = totalProductTax.ToString("C");
    }
}

}

I have UserControl which creates some disposable object in PageLoad.

private TeWorkspace workspace; //TeWorkspace is Disposable
protected void Page_Load(object sender, EventArgs e)
{
   workspace = new TeWorkspace(ContextWeb);
}

I want use this object in whole ASP.NET lifeCycle, but I need to be sure about disposing this object at the end o lifeCycle. So I overrided Contro.Dispose().

public override void Dispose()
{
    workspace.Dispose();
    base.Dispose();
}

My question is: whether my UserControl.Dispose will be called, if exception occurred in ASP.NET (somewhere in control lifeCycle)?

Thanks a lot

Update: So I try it and it looks like that Dispose is called when exception occurred.

i have 2 tables in database. kategori->kategoriID,kategoriAdet.....makale-> makaleID,kategoriID.. i can delete a "makale" row from database using this code in makaleler.aspx

<a href="makaleler.aspx?makaleID=<%#Eval("makaleID")%>&islem=sil">
 <img alt="" class="auto-style6" src="../tema/sil.jpg" /></a>

and i have this code in makaleler.aspx.cs

SQLbaglanti baglan=new SQLbaglanti();
string makaleID = "";
string islem = "";
protected void Page_Load(object sender, EventArgs e)
{


    makaleID = Request.QueryString["makaleID"];
    islem = Request.QueryString["islem"];
    if (islem == "sil")
    {
        SqlCommand cmdmsil = new SqlCommand("delete from Makale where makaleID='"+makaleID+"'", baglan.baglan());
        cmdmsil.ExecuteNonQuery();

    }

What i want to do is; when i press delete image and delete a "makale" , i want "kategoriAdet" decrease 1 point from "kategori" table and update with the new number...For example i have "makale A" , and "makale A" relates with "kategoriID=1", and "kategoriID=1" has the number 5 in "kategoriAdet" field in "kategori" table , when i delete makale A , the number in the "kategoriAdet" that it belongs to the ID should be 4... i wrote a code ,but it doesnt subtract the number , it does nothing , can anyone guide me what to do? Here is my code:

SQLbaglanti baglan=new SQLbaglanti();
    string makaleID = "";
    string islem = "";
    protected void Page_Load(object sender, EventArgs e)
    {


        makaleID = Request.QueryString["makaleID"];
        islem = Request.QueryString["islem"];
        if (islem == "sil")
        {

            // makale silince kategori adeti eksiltme 
            SqlCommand cmdkadet = new SqlCommand("update Kategori set kategoriAdet=kategoriAdet-1 FROM Kategori INNER JOIN Makale ON  Kategori.kategoriID=Makale.kategoriID  where makaleID='"+ makaleID+"'", baglan.baglan());
            cmdkadet.ExecuteNonQuery();

        }

I have a textbox where users will input their mobile numbers.

<input type="number" name="mobileNumber" id="mobileNumber" runat="server" />

I also have a dialog box where I used it as a confirmation when the users click on the submit button.

var answer = confirm("The number you have entered is <%= confirmNumber %>.\nPlease verify if the number you have entered is correct.")

if (!answer) {
    return false;
}

My expected output is here where __________ is supposed to be the value of the textbox.
(Apparently I don't have enough points to embed pictures yet?)

What I want to do is to retrieve the value from the textbox and replace the underscores in the dialog box with it.

Here is my C# attempt to retrieve the value from the textbox:

string confirmNumber = mobileNumber.Value;

I think that the C# code can only retrieve the value after the user has submitted? I am not really sure. Please help.

Actually i am trying to add a dialog box on the click of a button. But on the OnClick function of that button, i had already called function of a controller. The HTML code for this is:

<div class="pro-btn btn">
                        @{
<input type="button" id="place-bid-button-@Model.ProductId" class="button-1"value="@T("Nopaholics.Auction.AuctionDetailView.PlaceBid")" data-   productid="@Model.ProductId" 
onclick="Auction.placeBid('@Url.RouteUrl("Nopaholics.Auction.PlaceBid", new { productId = Model.ProductId, auctionId = Model.AuctionId })', '#product-details-form');return false;" />
}
</div>   

Now after writing below jquery, both click funtions are working simultaneously. But i want to first confirm by clicking OK button of dialog box and the controller action to be called.

<script> 
$('#place-bid-button-'+@Model.ProductId.ToString()).click(function(e){

$( "#dialog-confirm" ).dialog({
    resizable: false,
    height:160,
    modal: true,
    buttons: {
        "OK": function() {
            $( this ).dialog( "close" );
            $("#place-bid-button-@Model.ProductId.ToString()").click();
            },
            Cancel: function(e) {
                $( this ).dialog( "close" );
                $('#place-bid-button-'+@Model.ProductId.ToString()).die();
                console.log(e);
                //return false;
                //e.preventDefault();
            }
        }
    });
});
</script>

Any help would be appreciated. Thanks in advance..

I'm sure this has a simple answer. Forgive my ignorance; after 15 years of ASPNET WebForms this newfangled web v2.0 stuff is kicking my rear.

I'm trying to understand why my WebUser object is null on HttpPost.

So I have this controller action:

[HttpGet]
public ViewResult PrivateKey()
{
  var pk = new PrivateKey { WebUser = GetWebUserFromSession() };
  return View(pk);
}

This works fine and my razor view can access the members of PrivateKey.WebUser without issue.

The problem arises on the HttpPost action:

[HttpPost]
public ActionResult PrivateKey(PrivateKey pkey)
{
  if (string.IsNullOrEmpty(pkey.Value))
    return View(pkey);

  // pkey.WebUser is always null :(
  // TestKeyAgainstMockCipher(pkey.Value, pkey.WebUser);

  InsertSecuredMasterKeyIntoSession(pkey.Value);
  return RedirectToAction("Index", "Home");
}

So for a reason that I'm sure is totally legitimate, my PrivateKey object comes through the HttpPost okay but the referenced WebUser property contained within the PrivateKey object is always null.

I'm not sure if MVC requires a [Serializable] attribute be placed on the WebUser property or if I'm using the HttpPost incorrectly or even if its just accepted practice in MVC to continually run back to the I/O datastore to constantly fetch data rather than maintaining a standard object oriented data structure in memory to be passed around.

If it would help, here's the view I'm trying to get working:

@model KeePassWeb.Domain.Models.PrivateKey

@{
  ViewBag.Title = "PrivateKey";
  Layout = "~/Views/Shared/_MasterPage.cshtml";
}

@using (Html.BeginForm())
{
  <div class="privatekey">
    <table style="">
        <tr>
            <td style="width:128px; height: 75px;"></td>
            <td style="width:291px; height: 75px;"></td>
        </tr>
        <tr>
            <td style="width:128px; height: 25px;"></td>
            <td style="width:291px; height: 25px; ">
                @Html.PasswordFor(x =>x.Value, new { @class = "form-control", id="txtMasterPass", style = "width:65%", placeHolder = "Password" })
            <input Id="btnMasterPass" type="submit" value="Submit" class="submit" />
            </td>
        </tr>
    </table>
</div>

<table>
    <tr>
        <td><img src="../Images/big_info.png" height="32px" width="32px" style="margin-right:8px;" alt="info" /></td>
        <td>
            @if (string.IsNullOrEmpty(@Model.WebUser.Padding)) {
                @:This is your first login. Please create a private key passphrase.
            }
            else {
                @:Please enter your private key to access your wallet.
            }
        </td>
    </tr>
</table>
}
<script type="text/javascript">
  $("#wallet").addClass("active");
</script>

In short, I'm confused why the httpPost controller action is receiving a valid PrivateKey object from the postback but the objects contained within the PrivateKey object are always null.

Thanks in advance! --Oldtimer :)