I have created an excel spreadsheet using epplus library.

In this spreadsheet there are few columns with drop downs.

I need to make these drop downs searchable. We can make a drop down applied on a single cell, searchable using excel functions.

But it is not possible to apply the same on all the cells within a column.

But this is achievable using excel add-ins like 'excel campus-the-list-search-add-in' (https://members.excelcampus.com/products/the-list-search-add-in/categories/142180/posts/422610).

I don't want each and every user to install the excel add-in when they are using the spreadsheet created from my application.

I want the add-in to be automatically added, when creating the spreadsheet from my .NET application using epplus library.

I'm trying to load data from database using entity framework and ASP.Net MVC. But I got an InvalidOperationException error. How to fix this?

I've tried use tables with and without null data. But none of those work.

//Customers controller

public ViewResult Index()
        {
            var customers = _context.Customers.Include(c => 
c.MembershipType).ToList();

        }
//Customer model
public class Customer
        {
        public int Id { get; set; }
        [Required]
        [StringLength(255)]
        public string Name { get; set; }
        public bool IsSubscribedToNewsletter { get; set; }
        public MembershipType MembershipType { get; set; }
        public byte MembershipTypeId { get; set; }

        public DateTime? BirthDate { get; set; }
        }


 //customer view (index.cshtml)

It should displays the customers list. But when executing I got this error in customer controller.

I have jQuery call to get the data and a dropdown list on the UI, which is not populating the data. I have tried many ways, commented is the code I used. Let me know if I did something wrong in the code.

var questionData;
var optionData;

$(document).ready(function () {    
    $.ajax({
        url: 'coaching-assessment-tool.aspx/GetCATQuestionAndOptions',
        type: 'POST',
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        success: function (data) {            
            questionData = data.d[0];
            optionData = data.d[1];           
            console.log(questionData[0].QuestionText);
            console.log("Question Data", questionData);
            console.log("Option Data", optionData);
            //Questions
            document.getElementById('firstQuestion').innerHTML = questionData[0].QuestionText;
            document.getElementById('secondQuestion').innerHTML = questionData[1].QuestionText;
            document.getElementById('thirdQuestion').innerHTML = questionData[2].QuestionText;
            document.getElementById('fourthQuestion').innerHTML = questionData[3].QuestionText;
            document.getElementById('fifthQuestion').innerHTML = questionData[4].QuestionText;
            document.getElementById('sixthQuestion').innerHTML = questionData[5].QuestionText;
            document.getElementById('seventhQuestion').innerHTML = questionData[6].QuestionText;
            document.getElementById('eighthQuestion').innerHTML = questionData[7].QuestionText;
            document.getElementById('ninthQuestion').innerHTML = questionData[8].QuestionText;
            document.getElementById('tenthQuestion').innerHTML = questionData[9].QuestionText;
            //Responses
            //var ddlFirstResponse = document.getElementById('#ddlFirstResponse');
            //ddlFirstResponse.empty();
            $(function () {
                $('#ddlFirstResponse').append($("<option></option>").val('').html(''));
                $.each(optionData, function (key, value) {
                    //console.log('option: ' + value.OptionText + ' | id: ' + value.OptionId);
                    //$('#ddlFirstResponse').append($("<option></option>").val(value.OptionId).html(value.OptionText));
                    $("#ddlFirstResponse").append("<option value='" + value.OptionId + "'>" + value.OptionText + "</option>");
                });
            });            
        },
        error: function (error) {
            console.log(error);
            alert('Error retrieving data. Please contact support.');
        }        
    });
    
});


<asp:DropDownList ID="ddlFirstResponse" runat="server"></asp:DropDownList>

I want to set an html disabled attribute based on a viewmodel property.

I wrote:

<button disabled="@Model.prop">Button</button>

This works, but I'm not sure why. When true, it sets disabled="disabled", I would expect it to set disabled="True" which would disable the element by setting the disabled attribute at all. When false, the disabled attribute is entirely gone, whereas I would expect disabled="False" and for this to also disable the element.

I don't understand how this is being evaluated on the server when it generates the view so I was hoping someone could help me understand.

I'm building a program that searches documents in ASP.NET Core. I'm passing the search data from a text box to the controller through an Ajax request but the controller isn't receiving the string.

I've tried changing how the ajaxData field is defined, adding quotations around 'search' and even turning the whole thing into a string but I can't get it to pass to the controller.

This is the code for the request:

ajaxData = {search: $("#textSearchBox").val()}

console.log(ajaxData);

$.ajax({
    type: 'POST',
    url: "@Url.Action("GetDocuments", "DocumentSearchApi")",
    data: ajaxData,
    dataType: "json",
    contentType: "application/json; charset=utf-8",
    error: function (e) {
        //Error Function
    },
    success: function (jsonData) {
        //Success Function
    },
    fail: function (data) {
        //Fail Function
    }
});

And this is the top of the Controller's GetDocuments function:

[Route("GetDocuments")]
public async Task<IActionResult> GetDocuments(string search)
{

No error messages anywhere. The Console shows an Object that contains 'search: "Test"' but when I hit the breakpoint in GetDocuments 'search' is null.

Using ASP.NET Core 2.2 Razor Pages, I'm exploring binding radio buttons and dropdownlists to the page model.

Plenty of people are asking about client-side validation to "get it to work".

My question is: when I look at this code. Is there any server-side check being done by the binding engine?

@foreach (var gender in Model.Genders)
{
    <input type="radio" asp-for="Gender" value="@gender" id="Gender@(gender)" /> @gender
}

@Html.DropDownListFor(x => x.Country, new List<SelectListItem>
{
    new SelectListItem() {Text = "Canada", Value="CA"},
    new SelectListItem() {Text = "USA", Value="US"},
    new SelectListItem() {Text = "Mexico", Value="MX"}
})  

What's preventing someone from posting gender "bababa" and country "xxx", which could cause undefined behaviors in my code and database?

I'd be surprised if the above code is doing such validation (correct me if I'm wrong), and I couldn't find posts asking about that because everyone is asking about client-side validation.

What's the recommend approach here?

I want to set values of an <input> by a star rating in my asp.net mvc scaffolded create page

I found this html/css star rating form, but I don't know how to rewrite it that the value thats selected by the stars is passed into my asp.net-mvc model

So, I want to know how to rewrite this html form:

    <div class="txt-center">
        <form>
            <div class="rating">
                <input id="star5" name="star" type="radio" value="5" class="radio-btn hide" />
                <label for="star5" >☆</label>
                <input id="star4" name="star" type="radio" value="4" class="radio-btn hide" />
                <label for="star4" >☆</label>
                <input id="star3" name="star" type="radio" value="3" class="radio-btn hide" />
                <label for="star3" >☆</label>
                <input id="star2" name="star" type="radio" value="2" class="radio-btn hide" />
                <label for="star2" >☆</label>
                <input id="star1" name="star" type="radio" value="1" class="radio-btn hide" />
                <label for="star1" >☆</label>
                <div class="clear"></div>
            </div>
        </form>
    </div>

into this razor form:

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.LabelFor(model => model.SolutionRating, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.SolutionRating, new { htmlAttributes = new { @class = "rating" } })
                @Html.ValidationMessageFor(model => model.SolutionRating, "", new { @class = "text-danger" })
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create" class="btn btn-default" />
            </div>
        </div>
    </div>
}

I expect the model.solutionRating property to have the value 3 if I select 3 stars.

The ads not appear after I have removed and re-added the Adsense code.

I did not change and use the default code as

<ins class="adsbygoogle"
 style="display:block"
 data-ad-client="ca-pub-myid"
 data-ad-slot="id2"
 data-ad-format="auto"
 data-full-width-responsive="true"></ins>
 <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
</script>

How can I fix this ? Thanks

So I'm building a page named "Login" where the person with one account already in database can well do the login and entry in the "main page"

I have 2 Different Rolls: -Admin - Can create others accoutns, edit, delete etc...

-Normal user - Can't create another accounts, and it is just enable to read, not edit, delete etc...

I did a column in sql with the following name "function" where it keeps the roles as numbers...

1-admin

2-Normal User

But I'm not getting how I should use it, I did something like this:

protected void Button1_Click(object sender, EventArgs e)
        {
            using (SqlConnection sqlcon = new SqlConnection (@"Data Source=PEDRO-PC\SQLEXPRESS;Initial Catalog=costumizado;Integrated Security=True"))
            {


                string Select_Query = "SELECT COUNT(*) FROM Users where(Name= '" + TextBox1.Text + "' and Password ='" + TextBox2.Text +"');";
                Debug.Write(Select_Query);

                SqlCommand sqlcmd = new SqlCommand(Select_Query, sqlcon);
                sqlcmd.Connection = sqlcon;
          //      string query = "Select Funcao from Usuarios where(Function = 1);";
              //  SqlCommand sqlcmdd = new SqlCommand(query, sqlcon);
             //   sqlcmdd.ExecuteNonQuery();
                sqlcon.Open();
                int count = Convert.ToInt32(sqlcmd.ExecuteScalar());

                sqlcon.Close();

                if (count > 0 && function =="1" )
                {
                    Session["Name"] = TextBox1.Text;
                    Response.Cookies["TextBox1.Text"].Value = TextBox1.Text;
                    Response.Redirect("StartupAdmin.aspx");
                }

                else if (count > 0 && funcao =="2")
                {
                    Session["Name"] = TextBox1.Text;
                    Response.Cookies["TextBox1.Text"].Value = TextBox1.Text;
                    Response.Redirect("StartUpNormal.aspx");
                }


                else if (count == 0)
                {
                        TextBox1.Text = "";
                        TextBox2.Text = "";

                    }




            }
        }

ps: I know that doing this:

 if (count > 0 && function =="1" )

Doesn't make sense cause "Function" doesnt even is a variable, but but it was to show more or less what I wanted to do

I have method to submit data from client side to linqtosql entity. how ever I can not getting some input controls values. here is my method.

protected void btn_save_Click(object sender, EventArgs e)
    {
        List<string> file_names = new List<string>();
        string ToUser = txt_ComName3.Text.Trim();
        char touser1 = Convert.ToChar(ToUser.Substring(ToUser.Length - 1, 1));
        string Cc = null;
        if (!string.IsNullOrEmpty(txt_ComName4.Text.Trim()))
        {
            Cc = txt_ComName4.Text.Trim();
        }
        string Bcc = null;
        if (!string.IsNullOrEmpty(txt_ComName5.Text.Trim()))
        {
            Bcc = txt_ComName5.Text.Trim();
        }
        char? cc1 = null;
        if (!string.IsNullOrEmpty(Cc))
        {
            cc1 = Convert.ToChar(Cc.Substring(Cc.Length - 1, 1));
        }
        char? bcc1 = null;
        if (!string.IsNullOrEmpty(Bcc))
        {
            bcc1 = Convert.ToChar(Bcc.Substring(Bcc.Length - 1, 1));
        }
        bool FileAttached;
        if (FileUpload1.HasFile)
        {
            FileAttached = true;
        }
        else
        {
            FileAttached = false;
        }
        int templateId = 0;
        if (!string.IsNullOrEmpty(template_id.Value.Trim()))
        {
            templateId = Convert.ToInt32(template_id.Value.ToString());
        }
        else
        {
            templateId = 0;
        }
        using (DataClassesDataContext db = new DataClassesDataContext())
        {
            string Email = db.FromUsers.Where(f => f.EmailAddress.Equals(txt_ComName2.Text.Trim()) && f.user_id.Equals(int.Parse(CommonLogic.GetSessionValue("user_id").ToString()))).Select(f => f.EmailAddress).FirstOrDefault();
            string Host = db.FromUsers.Where(f => f.EmailAddress.Equals(txt_ComName2.Text.Trim()) && f.user_id.Equals(int.Parse(CommonLogic.GetSessionValue("user_id").ToString()))).Select(f => f.Host).FirstOrDefault();
            string Port = db.FromUsers.Where(f => f.EmailAddress.Equals(txt_ComName2.Text.Trim()) && f.user_id.Equals(int.Parse(CommonLogic.GetSessionValue("user_id").ToString()))).Select(f => f.Port).FirstOrDefault().ToString();
            string Password = db.FromUsers.Where(f => f.EmailAddress.Equals(txt_ComName2.Text.Trim()) && f.user_id.Equals(int.Parse(CommonLogic.GetSessionValue("user_id").ToString()))).Select(f => f.Password).FirstOrDefault();
            bool EnableSSl = db.FromUsers.Where(f => f.EmailAddress.Equals(txt_ComName2.Text.Trim()) && f.user_id.Equals(int.Parse(CommonLogic.GetSessionValue("user_id").ToString()))).Select(f => f.EnableSSL).FirstOrDefault();
            if ((String)Session["new_flag"] == "True")
            {
                var searchfromuser = db.FromUsers.Where(f => f.EmailAddress.Equals(txt_ComName2.Text.Trim()) && f.user_id.Equals(int.Parse(CommonLogic.GetSessionValue("user_id").ToString()))).Select(f => f).FirstOrDefault();
                if (searchfromuser != null)
                {
                    int fromuserid = int.Parse(searchfromuser.Id.ToString());
                    Email myEmail = new Email();
                    myEmail.Title = txt_ComName1.Text.Trim();
                    myEmail.IsDraft = false;
                    myEmail.FromUser = fromuserid;
                    myEmail.ToUser = (touser1 == ',') ? ToUser.TrimEnd(',') : ToUser;
                    if (!string.IsNullOrEmpty(Cc))
                    {
                        myEmail.Cc = (cc1 == ',') ? Cc.TrimEnd(',') : Cc;
                    }
                    if (!string.IsNullOrEmpty(Bcc))
                    {
                        myEmail.Bcc = (bcc1 == ',') ? Bcc.TrimEnd(',') : Bcc;
                    }
                    myEmail.Body = CKEditor1.Text.Trim();
                    myEmail.IsFileAttached = FileAttached;
                    myEmail.SentDateTime = DateTime.Now;
                    myEmail.user_id = int.Parse(CommonLogic.GetSessionValue("user_id").ToString());
                    db.Emails.InsertOnSubmit(myEmail);
                    db.SubmitChanges();
                    int newId = int.Parse(myEmail.Id.ToString());
                    HttpFileCollection fileCollection = Request.Files;
                    double tot_file_size = 0;
                    for (int i = 0; i < fileCollection.Count; i++)
                    {
                        File myFile = new File();
                        HttpPostedFile uploadfile = fileCollection[i];
                        string fileTitle = Path.GetFileName(uploadfile.FileName);
                        string fileName = DateTime.Now.ToString("ddMMyyyy_HHmmss");
                        string fileType = System.IO.Path.GetExtension(fileTitle).ToString().ToLower();
                        myFile.Email_Id = newId;
                        myFile.File_Title = fileTitle;
                        myFile.File_name = fileName;
                        myFile.File_ext = fileType;
                        double file_size = int.Parse(uploadfile.ContentLength.ToString()) / 1024;
                        tot_file_size += file_size;
                        myFile.File_Size = file_size;
                        if (uploadfile.ContentLength > 0)
                        {
                            uploadfile.SaveAs(Server.MapPath("~/EmailFiles/") + fileName + fileType);
                            db.Files.InsertOnSubmit(myFile);
                            db.SubmitChanges();
                            file_names.Add(fileName + fileType);
                        }
                    }
                    db.UpdateEmailField(newId, "TotalFileSize", tot_file_size.ToString());
                    string sbody = ConvertAllString(CKEditor1.Text.Trim());
                    DAL_General.SendReplyMail(newId, txt_ComName1.Text.Trim(), Host, Port, EnableSSl, Email, Password, (touser1 == ',') ? ToUser.TrimEnd(',') : ToUser, (cc1 == ',') ? Cc.TrimEnd(',') : Cc, (bcc1 == ',') ? Bcc.TrimEnd(',') : Bcc, sbody, file_names.ToList(), int.Parse(CommonLogic.GetSessionValue("user_id").ToString()), templateId);
                    int Subcount = 0;
                    string toUser = (touser1 == ',') ? ToUser.TrimEnd(',') : ToUser;
                    if (toUser.Contains(","))
                    {
                        string[] values = ToUser.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        for (int s = 0; s < values.Length; s++)
                        {
                            Subcount++;
                        }
                    }
                    else
                    {
                        Subcount = 1;
                    }
                    string Ccs = (cc1 == ',') ? Cc.TrimEnd(',') : Cc;
                    if (!string.IsNullOrEmpty(txt_ComName4.Text.Trim()))
                    {
                        string[] values1 = Ccs.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        for (int c = 0; c < values1.Length; c++)
                        {
                            Subcount++;
                        }
                    }
                    string Bccs = (bcc1 == ',') ? Bcc.TrimEnd(',') : Bcc;
                    if (!string.IsNullOrEmpty(txt_ComName5.Text.Trim()))
                    {
                        string[] values2 = Bccs.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        for (int b = 0; b < values2.Length; b++)
                        {
                            Subcount++;
                        }
                    }
                    db.ExecuteCommand(@"UPDATE [dbo].[tbl_From_master] SET [SentDateTime] = GETDATE() WHERE [Id]='" + fromuserid + "'");
                    db.ExecuteCommand(@"UPDATE [dbo].[tbl_From_master] SET [Count] = '" + Subcount + "' WHERE [Id]='" + fromuserid + "'");
                    var loggedMessage = db.LoggedMessages.Where(l => l.email_id.Equals(newId)).Select(l => l).ToList();
                    foreach (var message in loggedMessage)
                    {
                        if (message.Sent == true)
                        {
                            ShowAlert("Mail Sent Successfully.", this);
                        }
                        else if (message.Sent == false)
                        {
                            ShowAlert(message.SmtpException.ToString() + "&nbsp;&nbsp;" + message.InnerExceptionDetails.ToString(), this);
                        }
                    }
                }
                else
                {
                    ShowAlert("From User doesn't exist in record.", this);
                }
            }
            else if ((String)Session["new_flag"] == "False")
            {
                var searchfromuser = db.FromUsers.Where(f => f.EmailAddress.Equals(txt_ComName2.Text.Trim()) && f.user_id.Equals(int.Parse(CommonLogic.GetSessionValue("user_id").ToString()))).Select(f => f).FirstOrDefault();
                if (searchfromuser != null)
                {
                    int fromuserid = int.Parse(searchfromuser.Id.ToString());
                    db.UpdateEmail(int.Parse(email_id.Value.ToString()), txt_ComName1.Text.Trim(), fromuserid, (touser1 == ',') ? ToUser.TrimEnd(',') : ToUser, (cc1 == ',') ? Cc.TrimEnd(',') : Cc, (bcc1 == ',') ? Bcc.TrimEnd(',') : Bcc, CKEditor1.Text.Trim(), FileAttached, DateTime.Parse(System.DateTime.Now.ToString()));
                    db.SubmitChanges();
                    HttpFileCollection fileCollection = Request.Files;
                    double tot_file_size = 0;
                    for (int i = 0; i < fileCollection.Count; i++)
                    {
                        File myFile = new File();
                        HttpPostedFile uploadfile = fileCollection[i];
                        string fileTitle = Path.GetFileName(uploadfile.FileName);
                        string fileName = DateTime.Now.ToString("ddMMyyyy_HHmmss");
                        string fileType = System.IO.Path.GetExtension(fileTitle).ToString().ToLower();
                        myFile.Email_Id = int.Parse(email_id.Value.ToString());
                        myFile.File_Title = fileTitle;
                        myFile.File_name = fileName;
                        myFile.File_ext = fileType;
                        double file_size = int.Parse(uploadfile.ContentLength.ToString()) / 1024;
                        tot_file_size += file_size;
                        myFile.File_Size = file_size;
                        if (uploadfile.ContentLength > 0)
                        {
                            uploadfile.SaveAs(Server.MapPath("~/EmailFiles/") + fileName + fileType);
                            db.Files.InsertOnSubmit(myFile);
                            db.SubmitChanges();
                            file_names.Add(fileName + fileType);
                        }
                    }
                    var fileNames = db.Files.Where(f => f.Email_Id.Equals(int.Parse(email_id.Value.ToString()))).Select(f => f).ToList();
                    if (fileNames.Count > 0)
                    {
                        foreach (var item in fileNames)
                        {
                            file_names.Add(item.File_name.ToString() + item.File_ext.ToString());
                        }
                    }
                    db.UpdateEmailField(int.Parse(email_id.Value.ToString()), "TotalFileSize", tot_file_size.ToString());
                    string sbody = ConvertAllString(CKEditor1.Text.Trim());
                    DAL_General.SendReplyMail(int.Parse(email_id.Value.ToString()), txt_ComName1.Text.Trim(), Host, Port, EnableSSl, Email, Password, (touser1 == ',') ? ToUser.TrimEnd(',') : ToUser, (cc1 == ',') ? Cc.TrimEnd(',') : Cc, (bcc1 == ',') ? Bcc.TrimEnd(',') : Bcc, sbody, file_names.ToList(), int.Parse(CommonLogic.GetSessionValue("user_id").ToString()), templateId);
                    int Subcount = 0;
                    string toUser = (touser1 == ',') ? ToUser.TrimEnd(',') : ToUser;
                    if (toUser.Contains(","))
                    {
                        string[] values = ToUser.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        for (int s = 0; s < values.Length; s++)
                        {
                            Subcount++;
                        }
                    }
                    else
                    {
                        Subcount = 1;
                    }
                    string Ccs = (cc1 == ',') ? Cc.TrimEnd(',') : Cc;
                    if (!string.IsNullOrEmpty(txt_ComName4.Text.Trim()))
                    {
                        string[] values1 = Ccs.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        for (int c = 0; c < values1.Length; c++)
                        {
                            Subcount++;
                        }
                    }
                    string Bccs = (bcc1 == ',') ? Bcc.TrimEnd(',') : Bcc;
                    if (!string.IsNullOrEmpty(txt_ComName5.Text.Trim()))
                    {
                        string[] values2 = Bccs.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        for (int b = 0; b < values2.Length; b++)
                        {
                            Subcount++;
                        }
                    }
                    db.ExecuteCommand(@"UPDATE [dbo].[tbl_From_master] SET [SentDateTime] = '" + DateTime.Now.Date.ToString() + "' WHERE [Id]='" + fromuserid + "'");
                    db.ExecuteCommand(@"UPDATE [dbo].[tbl_From_master] SET [Count] = '" + Subcount.ToString() + "' WHERE [Id]='" + fromuserid + "'");
                    var loggedMessage = db.LoggedMessages.Where(l => l.email_id.Equals(int.Parse(email_id.Value.ToString()))).Select(l => l).ToList();
                    foreach (var message in loggedMessage)
                    {
                        if (message.Sent == true)
                        {
                            ShowAlert("Mail Sent Successfully.", this);
                        }
                        else if (message.Sent == false)
                        {
                            ShowAlert(message.SmtpException.ToString() + "&nbsp;&nbsp;" + message.InnerExceptionDetails.ToString(), this);
                        }
                    }
                }
            }
            Panel_AddNew.Visible = false;
            Panel_ViewList.Visible = true;
            Get_Data(Session["commandName"].ToString());
        }
    }

here it is I can not getting data from txt_ComName1.Text and CKEditor1.Text both are in update panel. and here is markup there :

<div class="portlet-body bordered" style="text-align: right;">
                                    <asp:Button ID="btn_saveAsdraft" runat="server" CssClass="btn blue"
                                        OnClientClick="return validate();" ValidationGroup="AddNewMail" Text="Save As Draft" OnClick="btn_saveAsdraft_Click" PostBackUrl='<%# Request.ServerVariables["URL"] %>' />
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <asp:Button ID="btn_save" runat="server" CssClass="btn green"
                                            OnClientClick="return validate();" ValidationGroup="AddNewMail" Text="Submit" OnClick="btn_save_Click" PostBackUrl='<%# Request.ServerVariables["URL"] %>' />
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btn_cancel" runat="server" CssClass="btn red" Text="Cancel" CausesValidation="False" OnClick="btn_cancel_Click" />
                                </div>
                            </div>
                        </div>
                    </div>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="ddl_subscribercategories" EventName="SelectedIndexChanged" />
                    <asp:AsyncPostBackTrigger ControlID="Img2" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="Img3" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="Img4" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="btn_saveAsdraft" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="btn_save" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="btn_cancel" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>

what i'm doing wrong here. please help me guys.....

Hi I am currently learning how to use itextsharp and am now having trouble with changing the border style (dashed border, dotted border, ect) for a table cell. I have been searching but all i am finding are ways for doing it for itext in jave. please help me break the wall I am looking at.

Hi so I'm currently learning how to work with iTextsharp and am having trouble on how to change the style of the borders (dashed, solid, dotted, double border, rounddots border) and all I'm finding are ways to do it in java. Please can help break down the wall I'm looking at.

                DataTable tb = helpers.dt_info();

                PdfPTable table = new PdfPTable(3);
                table.SetWidths(new float[] { 10f, 10f, 10f });
                table.WidthPercentage = 60;
                PdfPCell cell = new PdfPCell();

                cell = new PdfPCell(new Phrase("ID"));
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase("LANGUAGE"));
                table.AddCell(cell);

                cell = new PdfPCell(new Phrase("PLATFORM"));
                table.AddCell(cell);

                doc.Add(table);

                foreach (DataRow r in tb.Rows)
                {
                    table = new PdfPTable(3);
                    table.SetWidths(new float[] { 10f, 10f, 10f });
                    table.WidthPercentage = 60;


                    cell = new PdfPCell(new Phrase(r["id"].ToString()));
                    cell.BackgroundColor = BaseColor.GRAY;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    table.AddCell(cell);

                    cell = new PdfPCell(new Phrase(r["language"].ToString()));
                    cell.BackgroundColor = BaseColor.LIGHT_GRAY;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    table.AddCell(cell);

                    cell = new PdfPCell(new Phrase(r["platform"].ToString()));
                    cell.BackgroundColor = BaseColor.GRAY;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    table.AddCell(cell);

                    doc.Add(table);
                }
                doc.Close();

I am trying to call controller action method to render partial view to update the part of big web page. I am trying to do this on Ajax success function. Code Control Flow: Jquery Ajax calls a web api to add something to database, on the success function of the Ajax call, I am calling controller action method that returns partial view.

Jquery Script

 $(document).ready(function () {
            $("#sendMessage").on("click", function (e) {
                e.preventDefault();
                var MessageReplyParam = $('#messageToBeSent').val();
                var FromUserNameParam = $('#FromUserName').val();
                var FromUserIDParam = $('#FromUserID').val();
                var ToUserNameParam = $('#ToUserName').val();
                var ToUserIDParam = $('#ToUserID').val();
                var button = $(this);
                $.ajax({
                    //url: "/api/messages/SendMessages?MessageID=" + button.attr("data-message-id"),
                    url: "/api/messages/SendMessages",
                    method: "POST",
                    data: {
                        lngMessageID: button.data("message-id"),
                        Reply: MessageReplyParam,
                        FromUserID: FromUserIDParam,
                        FromUserName: FromUserNameParam,
                        ToUserID: ToUserIDParam,
                        ToUserName: ToUserNameParam
                    },
                    dataType: 'html',
                    success: function (data) {
                        $.ajax({
                            url: "/Booking/SendMessagesTest",
                            method: "POST",
                            data:
                            {
                                MessageID:2
                            }
                        });
                    }
                });
            });
        });

Controller method to update Partial View

    public ActionResult SendMessagesTest(int? MessageID)
        {          

            var messagesReplies = from mrp in _context.MessageReply
                                  where mrp.lngMessageID == MessageID
                                  select mrp;

            List<MessageReply> MessageReplies = new List<MessageReply>();
            MessageReplies = messagesReplies.ToList();

            BookingViewModel bvm = new BookingViewModel();

            bvm.MessageReplies = MessageReplies;

            return PartialView("_MessagesView", bvm);

        }

_MessagesView.cshtml

@model DatabaseMVCPractice.ViewModels.BookingViewModel
 @if (Model.MessageReplies != null)
        {
            foreach (var msg in Model.MessageReplies)
            {
                <p class="chatMessage">@msg.FromUserName: @msg.Reply</p>
            }
        }      

Main View that has other html and also render partial view of _MessageView

  <div id="partial">
            <div class="messages">
                <div class="bg-dark rounded padding-x4">
                    @{
                        Html.RenderPartial("_MessagesView", Model);
                    }
                </div>
                    <p>@Html.DisplayFor(model => model.Messages.Message)</p>
            </div>
         </div>

When I debug the code, control flow works properly, at last, it goes to _MessageView but it never goes to MainView to render the partial view on Ajax success function. What am I doing wrong?

In cshtml file, there is a form and i want to update the data without refresh the whole page only refresh that form. After Updation of form user spam count form value image is here I just enter the action method in form tag on which input tag value pass to the controller and update that value but whole page get refreshed but i want to refresh only that form.Befor Update any value

I have the following GridView defined in an ASP.Net page:

<asp:GridView ID="gv1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
  <Columns>
    <asp:BoundField DataField="Station" HeaderText="Station" HeaderStyle-Width="10%" SortExpression="Station" />
    <asp:BoundField DataField="Item1" HeaderText="Main Pos. at Station" HeaderStyle-Width="10%" SortExpression="Item1" />
    <asp:BoundField DataField="Max1" HeaderText="Max1" SortExpression="Max1" HeaderStyle-Width="5%" />
  </Columns>
 </asp:GridView>

The DataSource is defined by the following:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AppDBConnection %>"
  SelectCommand="SELECT [Station], [Item1], [Max1], FROM [tblSomeTable]">
</asp:SqlDataSource>

The Fields Item1 and Max1 contain comma separated lists, such that:

Item1="N100,N200,N300,N400"
Max1="70,80,90,100"

The issue is that I'd like to be able split the comma separated lists in to a list of separate items and display them within the BoundField, so that each entry is on a separate line.

Item1   Max1
N100    70
N200    80
N300    90
N400    100

What is the best way to accomplish this so that I can ensure that each item appears on it's own line within the grid cell?

Should I replace the commas (,) with spaces and use a stored procedure rather than inline SQL. (I could not get the Replace() function to work in the inline SQL).

I've tried turning wordwrap on for the column, but that did not seem to work.

What is the best way to achieve this?

Thanks,JohnB

I want to show image in view from database. I store imagepath in database so i want to give that path to img src but it does not work. Code is following:

Please help ....

The following code is in view

@{
   var FileName = db.UserImages.FirstOrDefault(x => x.UserID == User.Identity.Name).ImgName;
                        var serverpath = Server.MapPath("~/App_Data/ProfileImages/");
                        string filename = Path.GetFileName(FileName);
                        string fullpath = Path.Combine(serverpath, filename);

                        ViewBag.fullpath = fullpath;
}

<img src="@Url.Content("~/App_Data/ProfileImages/" + System.IO.Path.GetFileName(ViewBag.fullpath))" class="user-image" alt="User Image">

The image does not loaded where path is correct but it does not work

I made an MembersController.c# in Controller Folder but i give me and error on the page

Controller Code (Controller folder)

public class MembersController : SurfaceController
{
    [HttpPost]
    public ActionResult HandleLogin(string username, string password)
    {
        if (!Members.Login(username, password))
        {
            TempData["status"] = "Login failed";
        }
        return RedirectToCurrentUmbracoUrl();
    }
}

Umbraco Razor code

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Umbraco.Web.Controllers
@using Umbraco.Web.Models
@using System.Collections
@using System.Collections.Generic
@using System.Linq
@using Umbraco.Core.Services;
@using Umbraco.Web;

 @using (Html.BeginUmbracoForm<MembersController>("HandleLogin", null)){
   <h1>Test</h1> 
}

My error

Compiler Error Message: CS0246: The type or namespace name 'MembersController' could not be found (are you missing a using directive or an assembly reference?)

I created a HTML5 mock-up for a new page which would eventually become an editable form where users could update date fields. In plain HTML, I have something like this in the mock-up:

<input id="startDate" type="date" required runat="server">

In the final version, I have the above in a ListView with the date fields being populated from a DB:

    <ItemTemplate>
        <div class="col-sm-6">
            <div class="form-field">
                <label class="rentalLabel">View Start Date</label>
                <input id="viewStartDate" type="date" 
                    required runat="server">
            </div>
        </div>
        ....
    </ItemTemplate>

In the plain vanilla HTML version with type set to "date", the calendar pops up when the user focuses on the field, as desired. However, when I try to populate this field in the ListView the date being pulled from the DB does not appear, only "mm/dd/yyyy" and the calendar. If I remove the type="date" property, I get the date from the DB but lose the calendar?

What I would like to happen is to have the date from the DB appear, and the calendar pop up when a user focuses on that field to update the date? Any solution?

I use an ASP.net WebForm in a MVC application.
I need to redirect to a MVC View or to an ActionResult method in a Controller from WebForm Button Click Event.
Is there a way to do this?

public ActionResult Index()
{                                                             
    //Method in MVC Controller                                                                 
    //Rest of the code                                                    
}

Tried as below to redirect to a method in Controller:

protected void btnCreate_Click(object sender, EventArgs e)
{                    
    Response.Redirect("~/BreakdownReports/Index",false);
    Context.ApplicationInstance.CompleteRequest();                        
}

I'm getting this error like An extender can't be in a different UpdatePanel than the control it extends. i'm wondering what's wrong with my html markup :

<asp:Panel ID="Panel_AddNew" runat="server">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:HiddenField ID="hd" runat="server" />
                    <asp:HiddenField ID="template_id" runat="server" />
                     <table class="table text-center no-space table-bordered" style="vertical-align: middle; text-align: left;">
                                        <tr>
                                            <td style="width: 20%">Title
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txt_ComName1" runat="server" CssClass="form-control" ValidationGroup="AddNewMail" name="txt_ComName1"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2">
                                                <asp:UpdatePanel ID="UpdatePanel8" runat="server" UpdateMode="Conditional">
                                                    <ContentTemplate>
                                                        <table>
                                                            <tr>
                                                                <td style="width: 29%">Subscribers Category
                                                                </td>
                                                                <td>
                                                                    <asp:DropDownList ID="ddl_subscribercategories" Width="300px" Font-Bold="false" CssClass="form-control" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddl_subscribercategories_SelectedIndexChanged">
                                                                    </asp:DropDownList>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="width: 29%">From User </td>
                                                                <td>
                                                                    <table>
                                                                        <tr>
                                                                            <td>
                                                                                <asp:TextBox ID="txt_ComName2" runat="server" CssClass="form-control" ValidationGroup="AddNewMail" Width="500px" name="txt_ComName2"></asp:TextBox>
                                                                            </td>
                                                                            <td>&nbsp;&nbsp;</td>
                                                                            <td>
                                                                                <asp:ImageButton ID="Img5" runat="server" Height="30px" ImageUrl="~/img/1398451597_Table.png" ToolTip="Select From User" Width="25px" />
                                                                                <ajaxToolkit:ModalPopupExtender ID="MPE1" runat="server" BackgroundCssClass="modal-backdrop fade in" CancelControlID="btnclose" Enabled="True" PopupControlID="Panel_FromUser_master" TargetControlID="Img5">
                                                                                </ajaxToolkit:ModalPopupExtender>
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="width: 29%">To User </td>
                                                                <td>
                                                                    <table>
                                                                        <tr>
                                                                            <td>
                                                                                <asp:TextBox ID="txt_ComName3" runat="server" CssClass="form-control" ValidationGroup="AddNewMail" Width="500px" name="txt_ComName3"></asp:TextBox>
                                                                            </td>
                                                                            <td>&nbsp;&nbsp;</td>
                                                                            <td>
                                                                                <asp:ImageButton ID="Img2" runat="server" Height="30px" ImageUrl="~/img/1398451597_Table.png" ToolTip="Select To User Subscribers" Width="25px" OnClick="Img2_Click" />
                                                                                <ajaxToolkit:ModalPopupExtender ID="MPE" runat="server" BackgroundCssClass="modal-backdrop fade in" BehaviorID="mPopup" CancelControlID="ibtnclose" DynamicServicePath="" Enabled="True" PopupControlID="Panel_Subscriber_Master" TargetControlID="hd">
                                                                                </ajaxToolkit:ModalPopupExtender>
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="width: 29%">Cc </td>
                                                                <td>
                                                                    <table>
                                                                        <tr>
                                                                            <td>
                                                                                <asp:TextBox ID="txt_ComName4" runat="server" CssClass="form-control" ValidationGroup="AddNewMail" Width="500px" name="txt_ComName4"></asp:TextBox>
                                                                            </td>
                                                                            <td>&nbsp;&nbsp;</td>
                                                                            <td>
                                                                                <asp:ImageButton ID="Img3" runat="server" Height="30px" ImageUrl="~/img/1398451597_Table.png" ToolTip="Select Cc Subscribers" Width="25px" OnClick="Img3_Click" />
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="width: 29%">Bcc </td>
                                                                <td>
                                                                    <table>
                                                                        <tr>
                                                                            <td>
                                                                                <asp:TextBox ID="txt_ComName5" name="txt_ComName5" runat="server" Columns="10" CssClass="form-control" Rows="8" TextMode="MultiLine" ValidationGroup="AddNewMail" Width="500px"></asp:TextBox>
                                                                            </td>
                                                                            <td>&nbsp;&nbsp;</td>
                                                                            <td>
                                                                                <asp:ImageButton ID="Img4" runat="server" Height="30px" ImageUrl="~/img/1398451597_Table.png" ToolTip="Select Bcc Subscribers" Width="25px" OnClick="Img4_Click" />
                                                                            </td>
                                                                            <td>&nbsp;&nbsp;</td>
                                                                            <td>
                                                                                <asp:ImageButton ID="Img6" runat="server" Height="28px" ImageUrl="~/img/20100615143456!Icon-template.png" ToolTip="Select Template" Width="23px" />
                                                                                <ajaxToolkit:ModalPopupExtender ID="MPE3" runat="server" BackgroundCssClass="modal-backdrop fade in" CancelControlID="ImageButton4" DynamicServicePath="" Enabled="True" PopupControlID="Panel_Template_master" TargetControlID="Img6">
                                                                                </ajaxToolkit:ModalPopupExtender>
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </ContentTemplate>
                                                    <Triggers>
                                                        <asp:AsyncPostBackTrigger ControlID="ddl_subscribercategories" EventName="SelectedIndexChanged" />
                                                        <asp:AsyncPostBackTrigger ControlID="Img2" EventName="Click" />
                                                        <asp:AsyncPostBackTrigger ControlID="Img3" EventName="Click" />
                                                        <asp:AsyncPostBackTrigger ControlID="Img4" EventName="Click" />
                                                    </Triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="width: 20%">Email Body </td>
                                            <td>
                                                <asp:UpdatePanel ID="UpdatePanel34" runat="server" UpdateMode="Conditional">
                                                    <ContentTemplate>
                                                        <CKEditor:CKEditorControl ID="CKEditor1" runat="server" PasteFromWordRemoveFontStyles="False" ValidationGroup="AddNewMail" name="CKEditor1"></CKEditor:CKEditorControl>
                                                    </ContentTemplate>
                                                </asp:UpdatePanel>
                                                <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Email body is required." ForeColor="Red" ValidationGroup="AddNewMail"></asp:CustomValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="width: 20%">Attach Files </td>
                                            <td>
                                                <asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true" CssClass="multi" />
                                                <br />
                                                <asp:GridView ID="gv_file_list" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" GridLines="None">
                                                    <Columns>
                                                        <asp:TemplateField>
                                                            <ItemTemplate>
                                                                <asp:Button ID="Button1" runat="server" BackColor="White" BorderColor="White" BorderStyle="None" CommandArgument='<%# Eval("Id") %>' CommandName="DeleteFile" CssClass="theme-font" Font-Underline="True" Text="x" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:TemplateField>
                                                            <ItemTemplate>
                                                                <asp:Label ID="Label14" runat="server" Text='<%# Bind("File_Title") %>'></asp:Label>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                    </Columns>
                                                </asp:GridView>
                                                <br />
                                                <asp:Label ID="lblMessage" runat="server" />
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                                <div class="portlet-body bordered" style="text-align: right;">
                                    <asp:Button ID="btn_saveAsdraft" runat="server" CssClass="btn blue"
                                        OnClientClick="return validate();" ValidationGroup="AddNewMail" Text="Save As Draft" OnClick="btn_saveAsdraft_Click" />
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <asp:Button ID="btn_save" runat="server" CssClass="btn green"
                                            OnClientClick="return validate();" ValidationGroup="AddNewMail" Text="Submit" OnClick="btn_save_Click" />
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btn_cancel" runat="server" CssClass="btn red" Text="Cancel" CausesValidation="False" OnClick="btn_cancel_Click" />
                </ContentTemplate>
                <Triggers>
                    <asp:PostBackTrigger ControlID="btn_saveAsdraft" />
                    <asp:PostBackTrigger ControlID="btn_save" />
                    <asp:AsyncPostBackTrigger ControlID="btn_cancel" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
        </asp:Panel>

what was problem with this html markup??? .......................................................................................................................................................................................please help me

I'm trying to register a "Custom Control" (not a "User Control") on an aspx page from an assembly, but at runtime I get the error: "The directive is missing a 'src' attribute".

My Register directive on the page is:

<%@ Register TagPrefix="cc" Namespace="CMS.Controls.Content" Assembly="CMS.Controls" %>

As far as I know, the src attribute of the Register directive is only used when registering a "User Control" (i.e. a control defined by an ascx-file).

Why could I be getting this error when I'm registering a Custom Control via assembly? I made sure the assembly ("CMS.Controls.dll") is in the bin directory of my project.

I want to create a shopping cart, but i get this error. As you may see, i have the ShoppingCart class in the WebApplication1.App_Code namespace but when i try using WebApplication1.App_Code in the Default.aspx.cs, it does not work.

namespace WebApplication1.App_Code
{
    public class ShoppingCart
    {
        public List<CartItem> Items { get; private set; }

        public static readonly ShoppingCart Instance;

        static ShoppingCart()
        {
            if (HttpContext.Current.Session["ShoppingCart"] == null)
            {
                Instance = new ShoppingCart();
                Instance.Items = new List<CartItem>();
                HttpContext.Current.Session["ShoppingCart"] = Instance;
            }
            else
            {
                Instance = (ShoppingCart)HttpContext.Current.Session["ShoppingCart"];
            }
        }
using System;
using System.Data;
using System.Linq;
using WebApplication1.App_Code;
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnAddShoes_Click(object sender, EventArgs e)
        {
            ShoppingCart.Instance.AddItem(1);

            Response.Redirect("ViewCart.aspx");
        }