ASP.NET

123K

Solutions

28K

Contributors

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

Share tech news, updates, or what's on your mind.

Sign up to Post

How would you modify the following validation expression in ASP.NET  

^(\d){1,18}(\.\d{1,2})?$

to require a decimal point and ONLY 2 decimal places after the decimal point?

max value:           99,999,999,999,999.99

The value should be > 0.00
0
PeopleSoft Has Never Been Easier
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

I get this error at this part// string iDetailID = detail.EventDetail_ID.ToString(); // how do I solve it??
 protected void btnAdd_Click(object sender, EventArgs e)
    {
        string iDetailID = detail.EventDetail_ID.ToString();
        ShoppingCart.Instance.AddItem(iDetailID, detail);

        int ddlAmount, participants, itemNr;
        if (ValidateInput(out ddlAmount, out participants, out itemNr))
        {
            l1.Text = "";
            SetCookie();
            UpdateEventParticipantes(ddlAmount, itemNr);
            Response.Redirect(string.Format("Detail.aspx?id={0}", itemNr));
        }
    }

Open in new window

0
How would you modify the ValidationExpression to allow the input of only 2 decimal places?

ValidationExpression="(^(\$|)([1-9]\d{0,2}(\,\d{3})*|(([1-9]\d*))+|(0))\.\d{2}?$)">    

For example, a valid value "0.57".
0
I have an older website that build the home page by using an .aspx page as a frame, that includes other .aspx pages to make up the entire page. For example it is made up of about 4 different .aspx pages (i.e.: topMenu.aspx, leftPanel.aspx, righPanel.aspx, footer.aspx). These pieces are added by use of an include statement, into the HomePage.aspx.

  <!--leftPan -->
        <!--#include file ="../includes/leftPanel.aspx"-->
  <!--leftPan close -->

This is working but I need to make some changes to one of the included pages and I also need to add some C# code into the page. I've attempted to do this, based on my limited knowledge of this,  but am getting the following error:

Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30205: End of statement expected.

Source Error:


Line 1:  <Script Runat="Server">
Line 2:  		private void ibSearch_Click(object sender, System.Web.UI.ImageClickEventArgs e)
Line 3:  		{
Line 4:  			// Get search terms


Source File: E:\Sites\Intranet\includes\leftPanel2.aspx    Line: 2


Show Detailed Compiler Output:

Show Complete Compilation Source:


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1087.0 

Open in new window


my code is below:

<Script Runat="Server">
		private void 

Open in new window

0
Still pretty green to MVC and need some guidance on how to accomplish what was so simple in web forms. I have a dropdown filled with names from a database. Each of the records that contains those names, also contains an ID. On the same view, I have a label. What I want to do, is change the value of the label when the dropdown selection changes. A simple, static example of how to do this would be great. At the very least, I'd like to just be pointed in the right direction.
0
1 error saying
Feature 'interpolated strings' is not available in C# 5.  Please use language version 6 or greater.
here is the code!!
 protected void SetCookie()
    {
        if (Request.Cookies["aa"] != null)
        {
            Response.Cookies["aa"].Value = Request.Cookies["aa"].Value + "|";
        }

        Response.Cookies["aa"].Value = Request.Cookies["aa"].Value + $"{lblTitle.Text},{lblPrice.Text},{lblDate.Text},{lblLocation.Text},{lblStartTime.Text},{lblEndTime.Text},{lblParticipants.Text},{lblDescription.Text},{lblItemNr.Text},{imgEvent.ToString()}";
        Response.Cookies["aa"].Expires = DateTime.Now.AddDays(1);
    }

Open in new window

0
Dear Experts,

Can anybody help me to sort out the issue?

Issue Description : I need to get the textbox entered value in gridview at the time of linkbutton click event.

Design Page :
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="prefLine"
                                                    AllowPaging="True" AllowSorting="True"
                                                    OnPageIndexChanging="GridView1_PageIndexChanging" Width="100%" BackColor="White" BorderColor="#999999" EnableModelValidation="True" GridLines="Vertical">
                                                    <Columns>
                                                        <asp:TemplateField HeaderText="Edit" >
                                                            <ItemTemplate>
                                                                <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#String.Format("frmSls.aspx?id={0}&det={1}", HttpUtility.UrlEncode(Eval("nSlsID").ToString()), HttpUtility.UrlEncode(Eval("nSlsDetID").ToString())) %>'
                                                                    Text="Edit" CommandName="select">
                                                                </asp:HyperLink>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        

Open in new window

0
0
Hi Experts
I created a webform in my solution which also has Razor but not MVC,
When I run the website in Explorer, VS adds the vbhtml file extension to the aspx file extension and I get the error
The type of page you have requested is not served because it has been explicitly forbidden -  File.aspx.vbhtml
I have tried adding
<appSettings>
    <add key="webpages:Enabled" value="true" />
</appSettings>
But this didn't help
I have other web forms in the solution that do not have this problem
Appreciate any ideas
Thanks
0
I have a grid view that when the user select a button on the grid an user control will show on the bottom of the page with the details. As far as I can see the prerender part of the user control is not executing.

<asp:GridView ID="Grid" runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="Grid_SelectedIndexChanged" OnRowCancelingEdit="Grid_RowCancelingEdit" DataKeyNames="OrderId">

        <Columns>
            <asp:BoundField DataField="OrderId" HeaderText="Order Id" ReadOnly="True" SortExpression="OrderId" />
           
Removed some fields

Button field

            <asp:ButtonField ButtonType="Button" CommandName="Select" Text="Details" />
        </Columns>
    </asp:GridView>

User control called
        <uc2:CustOrderDetail  runat="server" ID="CustOrderDetail" Visible="False" />
When select button is selected Grid_SelectedIndexChanged is called
Session["OrderId"] = Grid.SelectedRow.Cells[0].ToString();
User control prerender code
protected void PreRender(object sender, EventArgs e)
    {
        if (Session["OrderId"] != null)
        {
            Populate();
            this.Visible = true;
     
        }
        else
        {
            this.Visible = false;
        }
    }
0
[Webinar] Learn How Hackers Steal Your Credentials
LVL 9
[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

There must be some thing there - the following two issues must be related to one reason, I spend two days to understand why

ISSUE 1
        var y2 = 2000;
        alert(y2);   (this line gives alert 2000 which means y2 value is 2000)
        alert(y2 == 2000);   (this line gives alert true which also means y2 value is 2000)

        if (y2 = 2000 ) {
            alert("y2 is equals 2000");    (never get to this alers !!!!!     any Idea?)
            return false;
        }

ISSUE 2
assuming textbox1.text="11-1-2000"
assuming textbox2.text="11-1-2001"

        var T1= document.getElementById("<%=Textbox1.ClientID%>");
        var year1 = T1.value.split("-")[2];
        var T2= document.getElementById("<%=Textbox2.ClientID%>");
        var year2 = T2.value.split("-")[2];
       
        alert(year1);   (this line gives alert 2000 which means T1 value is 2000)
        alert(year2);   (this line gives alert 2001 which means T2 value is 2001)
       
        if (year1 > Year2)
        {
            Alert("Year1 is GT Year2")   (never get to this alers !!!!!     any Idea?)
            return false;
        }
0
If user selects 5 on ddl and only 4 event participants are displayed, there will be a label asking user to select qty that is lower!! Now, when I click the button nothing changes and there is also a line underlining eventParticipants.
- The end of the cookies line are red too, and I think there is a problem with the image.url part?
code behind for the button
  protected void btnAdd_Click(object sender, EventArgs e)
    {
        var id = Convert.ToInt32(lblItemNr.Text);
        SqlConnection con = new SqlConnection(_connStr);
        if (con.State == ConnectionState.Open)
        {
            con.Close();
        }
        con.Open();
        SqlCommand cmd1 = con.CreateCommand();
        cmd1.CommandType = CommandType.Text;
        cmd1.CommandText = "update EventDetail set eventParticipants=eventParticipants-" + ddlAmount.Text + " where EventDetail_ID=" + id;
        cmd1.ExecuteNonQuery();
        Response.Redirect("Detail.aspx?id=" + id.ToString());
        //below are the codes with problems (eventParticipants)...
        if(Convert.ToInt32(ddlAmount.Text) > Convert.ToInt32(eventParticipants))
        {
            l1.Text = "please enter lower quantity";
        }
        else
        {
            l1.Text = "";

            if (Request.Cookies["aa"] == null)
            {
                Response.Cookies["aa"].Value = lblTitle.Text.ToString() + "," + lblPrice.Text.ToString() + "," + lblDate.Text.ToString() + "," + lblLocation.Text.ToString() + "," + 

Open in new window

0
If there is 0 participants available, I want a label saying 'no available participants for this event' so the user cannot select qty from dropdownlist!! But there is this error

   int qty;
    int id;
    protected void Page_Load(object sender, EventArgs e)
    {
        FillPage();
        qty = get_qty(id);
        if (qty == 0)
        {
            lblParticipants.Visible = false;
            ddlAmount.Visible = false;
            btnAdd.Visible = false;
            l2.Text = "no available participants for this event";          
        }
    }
   public int get_qty(int id)
    {
         id = Convert.ToInt32(lblItemNr.Text);
        SqlConnection con = new SqlConnection(_connStr);
        if (con.State == ConnectionState.Open)
        {
            con.Close();
        }
        con.Open();
        SqlCommand cmd = con.CreateCommand();
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "select * from EventDetail where id=" + id + "";
        cmd.ExecuteNonQuery();
        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(dt);
        foreach (DataRow dr in dt.Rows)
        {
            qty = Convert.ToInt32(dr["eventParticipants"].ToString());
        }
        return qty;
    }  

Open in new window

0
Hi,
Further to this
https://www.experts-exchange.com/questions/29042667/Add-button.html?anchor=a42220705¬ificationFollowed=192653361#a42220705

I adjust the column name in Javascript but the problem persists (I cannot delete the record), after re-deployment.
0
I have the following if statement but need to add else when the case 12,15,18,22 is not I only need to show the OutTracking and InTracking currently now it shows nothing if I have other than case 12,15,18,22.  I need to show without a hyperlink and plain text

[Rule("r100")]
        public void r100Implementation(string OutTracking, string OutTrackingAlias, string InTracking, string InTrackingAlias)
        {
            if (OutTracking != null)
                switch (OutTracking.Length)
                {
                    case 12:
                    case 15:
                    case 22:
                        // fedex
                        UpdateFieldValue("OutTrackingAlias", "<a href=\"https://www.fedex.com/fedextrack/?cntry_code=us&tab=1&tracknums="
                        + OutTracking
                        + "&clienttype=dotcom\" target='_blank'>"
                        + OutTracking
                        + "</a>");
                        break;
                    case 18:
                        // UPS
                        UpdateFieldValue("OutTrackingAlias", "<a href=\"http://wwwapps.ups.com/WebTracking/processInputRequest?sort_by=status&tracknums_displayed=1&TypeOfInquiryNumber=T&loc=en_US&InquiryNumber1="
                        + OutTracking
                        + "&clienttype=dotcom\" target='_blank'>"
                        + OutTracking
                        + "</a>");
                        break;
                }
               

Open in new window

0
1. When I click edit, I have to click it twice in order for the edit to work
2. Then shows the update, but all the items are not shown and when I click update -> it says 'result = det.EventDetailUpdate(int.Parse(id), int.Parse(tid), tname, tdate, decimal.Parse(tprice), tdesc, tlocation, tstart, tend, timage, int.Parse(tparticipants)); 'input string is not in correct format
what I did to update!!
   protected void abind()
    {
        List<EventDetail> detList = new List<EventDetail>();
        detList = aDet.getAllEventDetail();
        gvDetail.DataSource = detList;
        gvDetail.DataBind();
        //   ViewState["grdDetailsDataSource"] = (List<EventDetail>)gvDetail.DataSource;
    }  protected void gvDetail_RowEditing(object sender, GridViewEditEventArgs e)
    {
        gvDetail.EditIndex = e.NewEditIndex;
     //   abind();
    }
    protected void gvDetail_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        gvDetail.EditIndex = -1;
      //  abind();
    }
    protected void gvDetail_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int result = 0;
        EventDetail det = new EventDetail();
        GridViewRow row = (GridViewRow)gvDetail.Rows[e.RowIndex];
        string id = gvDetail.DataKeys[e.RowIndex].Value.ToString();
        string tid = ((TextBox)row.Cells[2].Controls[0]).Text;
        string tname = ((TextBox)row.Cells[3].Controls[0]).Text;
        string tdate = ((TextBox)row.Cells[4].Controls[0]).Text;
 

Open in new window

0
Hello,
How can I connect to a stored procedure and display its content on a web page which is desktop/ mobile friendly in a tabular form.
Regards
0
eg. I have 20 participants. When I select 2qty and click the button, it is supposed to have 18 participants!! However now when I click the button, the qy changes to 0 , and all the other participants no. for other events will change too..
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        var id = Convert.ToInt32(lblItemNr.Text);
    SqlConnection con = new SqlConnection(_connStr);
        if (con.State == ConnectionState.Open)
        {
            con.Close();
        }
        con.Open();
        SqlCommand cmd1 = con.CreateCommand();
        cmd1.CommandType = CommandType.Text;
        cmd1.CommandText = "update EventDetail set eventParticipants=eventParticipants-" + lblParticipants.Text;
        cmd1.ExecuteNonQuery();
        Response.Redirect("Detail.aspx?id=" + id.ToString());   
    }

Open in new window

0
<asp:GridView ID="gvType" runat="server" AutoGenerateColumns="False" OnRowDeleting="gvType_RowDeleting" DataKeyNames="EventType_ID" >
            <Columns> 
    <asp:TemplateField HeaderText="Select">
   <HeaderTemplate> <asp:CheckBox ID="chkAll" runat="server" onclick="javascript:SelectAllCheckboxes(this);" />  </HeaderTemplate>
   <ItemTemplate> <asp:CheckBox ID="chkSelect" runat="server" AutoPostBack="true" OnSelectedIndexChanged="Type_Selected" /> </ItemTemplate>
   </asp:TemplateField>
                 <asp:CommandField ShowDeleteButton="True" ShowEditButton="True"/>
                <asp:BoundField DataField="EventType_ID" HeaderText="EventType_ID" ReadOnly="True" SortExpression="EventType_ID" />
                <asp:BoundField DataField="EventTypeName" HeaderText="EventTypeName" SortExpression="EventTypeName" />
                </Columns>
        </asp:GridView>

Open in new window

Code behind Codes
 EventType aType = new EventType();
    protected void Page_Load(object sender, EventArgs e)
    {
       /* if (!this.IsPostBack)
        { this.BindGrid(); } */

        if (!IsPostBack)
        {
            bind();
        }
    }
    protected void bind ()
    {
        List<EventType> eveList = new List<EventType>();
        eveList = aType.getAllEventType();
        gvType.DataSource = eveList;
        gvType.DataBind();
    }
  protected void gvType_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int result = 0;
        EventType type = new EventType();
        string categoryID = gvType.DataKeys[e.RowIndex].Value.ToString();
        result = type.EventTypeDelete(categoryID);
    }

Open in new window

class code
 public int EventTypeDelete(string ID)
    {
        string queryStr = "DELETE FROM EventType WHERE EventType_ID=@ID";
        SqlConnection conn = new SqlConnection(_connStr);
        SqlCommand cmd = new SqlCommand(queryStr, conn);
        cmd.Parameters.AddWithValue("@ID", ID);
        conn.Open();
        int nofRow = 0;
        nofRow = cmd.ExecuteNonQuery();
        conn.Close();
        return nofRow;

    }//end Delete 

Open in new window

0
Creating Instructional Tutorials  
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Here is my aspx page
 <asp:GridView ID="grdDetails" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" DataKeyNames="EventDetail_ID" ForeColor="Black" GridLines="Vertical" Width="85%" OnPageIndexChanging="grdDetails_PageIndexChanging" OnRowDeleting="grdDetails_RowDeleting">
            <AlternatingRowStyle BackColor="#CCCCCC" />
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="EventDetail_ID" HeaderText="EventDetail_ID" ReadOnly="True" SortExpression="EventDetail_ID" />
                <asp:BoundField DataField="EventType_ID" HeaderText="EventType_ID" SortExpression="EventType_ID" />
                <asp:BoundField DataField="eventDetailName" HeaderText="eventDetailName" SortExpression="eventDetailName" />
                <asp:BoundField DataField="eventDate" HeaderText="eventDate" SortExpression="eventDate" />
                <asp:BoundField DataField="eventPrice" HeaderText="eventPrice" SortExpression="eventPrice" />
                <asp:BoundField DataField="eventDesc" HeaderText="eventDesc" SortExpression="eventDesc" />
                <asp:BoundField DataField="eventLocation" HeaderText="eventLocation" SortExpression="eventLocation" />
                <asp:BoundField DataField="startTime" HeaderText="startTime" SortExpression="startTime"

Open in new window

0
When the session times out it redirects to the login page with a query string identifying the previous page.

login.aspx?ReturnUrl=%2fLoggedIn%2fMyWorkOuts.aspx

 I would like to be able to remove the query string and just redirect to the login in page. Is this possible? If so how do I go about it?

Thanks,
Doug
0
I'm trying to filter a gridview from a gridview with checkboxes!! I have this error at
' if (chk.Checked)'
Below is part of the code!!

  private void BindGrid()
    {
        string constr = ConfigurationManager.ConnectionStrings["EventContext"].ConnectionString;
        string query = "SELECT EventDetail_ID, EventType_ID, EventDetailName, eventDate, eventPrice, eventDesc, eventLocation, startTime, endTime, eventImage, eventParticipants FROM EventDetail";

        string condition = string.Empty;

        foreach (GridViewRow row in grdDetails.Rows)
        {
            CheckBox chk = (CheckBox)row.FindControl("chkSelect");
            if (chk.Checked)
            {
                string eventtypeid = row.Cells[0].Text;   
                // i am trying to get the bounded field value of eventtype ID field here
                condition += string.Format("'{0}',", eventtypeid);
            }
        }
        if (!string.IsNullOrEmpty(condition))
        {
            condition = string.Format(" WHERE EventType_ID IN ({0})", condition.Substring(0, condition.Length - 1));
        }
        using (SqlConnection con = new SqlConnection(constr))
        {
            using (SqlCommand cmd = new SqlCommand(query + condition))
            {
                using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
                {
                    cmd.Connection = con;
                    using (DataTable dt = new DataTable())
                    {
                        

Open in new window

0
Below is my code behind. When I click the add to cart button, the qty(eventParticipants) should decrease but it doesn't. Also, it says the name id does not exist in the current context for the id in the btnAdd_Click part below~~

 string _connStr = ConfigurationManager.ConnectionStrings["EventContext"].ConnectionString;

    protected void Page_Load(object sender, EventArgs e)
    {
        FillPage();
    }
    private void FillPage()
    { 
        if(Request.QueryString["id"] == null)
        {
            Response.Redirect("Events.aspx");
        }
        else
        {
            //get selected event's data
            if (!String.IsNullOrWhiteSpace(Request.QueryString["id"]))
            {
                int id = Convert.ToInt32(Request.QueryString["id"]);

                EventDetail Detail = new EventDetail();
                EventDetail detail = Detail.getEventDetail(id);
                if (detail == null)
                {
                    Response.Write("<script>alert('No event found');</script>");
                    return;
                }
                //fill pg w data
                lblDate.Text = detail.eventDate;
                lblLocation.Text = detail.eventLocation;
                lblStartTime.Text = detail.startTime;
                lblEndTime.Text = detail.endTime;
                lblParticipants.Text = detail.eventParticipants.ToString();
                lblPrice.Text = "$" + detail.eventPrice;
                lblTitle.Text = 

Open in new window

0
In my .net c# project I have two jason like this

Json1
{"WindowsServices":[{"name":"SNMP","statusID":"1","StatusMsg":"Stopped","FullStatus":"SNMP,1"},{"name":"SNMPTRAP","statusID":"1","StatusMsg":"Stopped","FullStatus":"SNMPTRAP,1"}]}

Open in new window


Json2
{"WindowsServices":[{"name":"SNMP","statusID":"4","StatusMsg":"Running","FullStatus":"SNMP,4"},{"name":"SNMPTRAP","statusID":"1","StatusMsg":"Stopped","FullStatus":"SNMPTRAP,1"}]}

Open in new window


I need to compare this to json and get the result of the modified part oly
{"WindowsServices":[{"name":"SNMP","statusID":"4","StatusMsg":"Running","FullStatus":"SNMP,4"}]}

Open in new window



Thank you for your help!!
0
I have a textbox that use for my calendar

$("#txtDueBackDate").datepicker({
            formatDate: data.formatDueBackDate,
        });

Open in new window


When user initiates the page the textbox filled up with a date like 7\12\2017.
Now when I click on the calendar I would like to highlight two dates
1. the date of today.
2. the date which show at the textbox.

Please, Help.

Thanks,
0

ASP.NET

123K

Solutions

28K

Contributors

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications