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

I think I am still having a Session issue. I am also noticing that when I leave my web page alone for a while I will come back and I will be on my Expired Session page. But sometimes, while Im working, I notice that my page will do a postback without me doing anything.
I would LOVE to find out the following  
A.) what is causing this to postback out of nowhere
B.) if its not the Session ending how can I find out what is causing my app to postback by itself?

This is causing the app to start from ground zero, so to speak...
For instance, I have a datalist on the left of the screen and it has timesheets by weeks,  that when selected they fill a gridview and blablabla....I could be working on the 3rd timesheet in the list but when this postback happens it goes back to the first timesheet as if you were coming to the page for the first time.....Im hoping this makes sense

Bottom line is, I think Session ending is causing this to happen but it does NOT always redirect to my Session Expire screen for some reason??? Sometimes it does but other times...not so much!!

My code in all of my MAIN page loads are the following...
        'Check for Session State and if gone then redirect to Expired form
        Response.AddHeader("Refresh", Convert.ToString((Session.Timeout * 60) + 5))
        If Session.IsNewSession Then
            Me.Master.PageLabel = ""
            Server.Transfer("SessionExpired.aspx")
        End If

Open in new window


I think I need to use this Response.AddHeader code to possibly send me a message box before Session ends and somehow extend session if the user wants to stay logged in? Has anyone ran into this before? I cant be the only one this has happened to??
Any help would really be appreciated
0
New benefit for Premium Members - Upgrade now!
LVL 9
New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

I have a modalPopupExtender control with a Panel and inside the Panel I have an iFrame thats source is another form. This is the way my boss wanted it done. So in the other form where I have 3 different html tables. So whenever this form gets called up it will know which table  should be visible and which should not. This is all fine. My only problem is resizing my panel and iFrame. When the modalPopupExtender gets called the iFrame is either too big and the Panel too small or vice cersa. Now, in my calling form I have a procedure that checks the browser and sets the height accordingly(the width of the iFrame is set to 95% and that, for some reason, works?? But the height is my nemesis and, like I said, depending on which html table will show is dependent on the height that should be set.
This CANT be so hard that I have to deal with major gaps in my form/popup. It looks horrble. I have attached a pictures of the 3 different heights I need and Im hoping that someone can let me know what Im doing wrong and an easy way to go about fixing it...

FYI, the 3 pics I have attached are in IE and they are worse in the other browsers.
I can deal with 1 and 3 but the 2nd pic attached is unacceptable....

Thanks in advance....And anything needed from me please ask and I will send it right over

PLEASE HELP ME!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Problem 1Problem 2Problem 3
0
I have a form with Submit.
I need to append a hashtag (#) so I can open the page and goto an anchor called '#searchresults'.
Here is my code;

	
var searchTerm = Request.QueryString("qa_searchForm")
Out ('<form action="" method="get" style="vertical-align:middle; margin:20px 0px 0px 0px; background:url(images/Community/graphic_com_search_field.jpg) no-repeat">');
Out ('<input type="text" value="Enter search terms here to search ALL categories..." name="qa_searchForm" style="width:360px; font-size:1em; margin-left:60px; height:39px; line-height:39px; background-color:#EAE8D4; border:0; vertical-align:middle; color:gray;" onblur="if(this.value==&#39;&#39;) { this.value=&#39;Enter search terms here to search ALL categories...&#39; }" onfocus="if(this.value==&#39;Enter search terms here to search ALL categories...&#39;) { this.value=&#39;&#39; }"/>');
Out ('<input type="hidden" value="'+nPage+'" name="page"/>');

Open in new window


I am using a hidden value to insert the page number (variable nPage).
If I enter "test", the resulting querystring is:

/default.aspx?qa_searchForm=test&page=Retailer-QA

So far, so good.

If I try to add another hidden value:
Out ('<input type="hidden" value="#searchresults" name="anchor"/>');

Open in new window


I get the following result:
/default.aspx?qa_searchForm=test&page=Retailer-QA&anchor=%23searchresults&x=90&y=17

What do I do to get the following needed querystring that has the anchor '#searchresults':

/default.aspx?qa_searchForm=test&page=Retailer-QA&anchor=#searchresults

Thanks!
Russ :)
0
I came across this site and it has the answer to the questions. I want to know why the answers are that.

   public class A
        {
            public A()
            {
                var p = "In A";
            }

            static A()
            {
                var p = "in Static A";
            }

            public void Method()
            {
                var p = "In Method A";
            }

        }



        public class B:A
        {
            public B()
            {
                var p = "In B";
            }

            static B()
            {
                var p = "in Static B";
            }

            public void Method()
            {
                var p = "In Method B";
            }

        }

Open in new window


1. A a = new A();  -- Why does it call the "In static A" first and then "In A"?  Static methods can't be called with "new"

2. B b = new A();  -- why is this an error? B inherits from A

3. A c = new B();  -- this calls "in static B" first, then "in Static A", then "In A" and then "In B".  Same as #1. Why is it calling "static" method first?  It inherits from A ...that's why it calls "in Static A", then "In A" next, correct?
0
I have:
action="https://test.secure.touchnet.net:8443/****.jsp" method="post" target="_self" id="hidden_calc"
<input type="hidden" name="UPAY_SITE_ID" value="*">
<input type="hidden" name="EXT_TRANS_ID" value="whatever">

I need to add
<input type = "hidden" name = "BILL_NAME" value = "aName">
<input type = "hidden" email = "email" value = "aName@gmail.com">

I need to have this all run in the code behind.

any help will be appreciated
0
Hi,

The code I have below has been working fine without parameters. I added a new parameter into sp, (the sp is working), but I am getting

Newline in constant

from ASP.net, any ideas?  thanks
    private void load1(SqlConnection sqlConnection)
    {

        SqlCommand connLoad = new SqlCommand("st_test", sqlConnection);
        connLoad.CommandType = CommandType.StoredProcedure;           
        connLoad.Parameters.Add("@Category, System.Data.SqlDbType.VarChar, 20).Value = "test";//Request.QueryString["category"];

        SqlDataAdapter da = new SqlDataAdapter(connLoad);

        using (DataTable dt = new DataTable())
        {

            da.Fill(dt);
            using (XLWorkbook wb = new XLWorkbook())
            {
                
                var ws = wb.Worksheets.Add(dt, "123");
                ws.Row(1).Style
                        .Fill.SetBackgroundColor(XLColor.YaleBlue)
                        .Font.SetBold();

                Response.Clear();
                Response.Buffer = true;
                Response.Charset = "";
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment;filename=myexcel.xlsx");
                //Response.TransmitFile(FilePath); 

                using (MemoryStream MyMemoryStream = new MemoryStream())
                {

                    wb.SaveAs(MyMemoryStream);
                    

Open in new window

0
I've been using an iframe to embed content from a 3rd party vendor for over a year now but recently, particularly in Chrome, the content on the page is flashing and not fully loading, ever, so it seems. I haven't changed my code (see below) so I'm not sure what the problem is. I'm researching solutions but they all seem very complicated at that point, if they would even work. Some involve php and I'm not familiar with that AT ALL so I don't know if that is even an viable option. Please help?

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="SFATouchTasks.aspx.cs" Inherits="SFATouchTasks" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    <style type="text/css">
        .page
        {
            width: 1150px;
            height: 100%;
        }        
        .header
        {
            background: #FFF;
            width: 100%;
        }        
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <div id="divEmbed" style="height: 300px;">
        <iframe id="ifm" name="ifm" width="100%" height="300%" frameborder="0" src="http://x.x.xxx.xxx:xxxx/app/main#/dashboards/589e1fed677202f430000031?embed=true"
            scrolling="auto" style="float: left;"></iframe>
    </div>
</asp:Content>

Open in new window

0
I have an MVC application. I am new to MVC. I have a HomeController with a function, getUserId,  that returns the UserId of the current user. I want to display the result of that function in my index.cshtml page. Something like "Your are logged in as: smtihs". How do I call the result of the function from the cshtml page? Thanks for any help.
0
Hi HainKurt,

Perhaps, you can help me one more time on this?

I am trying to remove a dynamically generated row in Repeater.

The code below is generating an error:

protected void btnDelete_Click(object sender, EventArgs e)
{
    int rowIndex = 0;
    int rowID = e.RowIndex;
    lblTotal.Text = "0";
    if (ViewState["CurrTable"] != null)
    {
        DataTable dtCurrentTable = (DataTable)ViewState["CurrTable"];
        if (dtCurrentTable.Rows.Count > 0)
        {
            for (int i = 1; i <= Repeater1.Items.Count; i++)
            {
                TextBox tbboatregNum = (TextBox)Repeater1.Items[rowIndex].FindControl("txtboatregNum");
                TextBox tbPayerret = (TextBox)Repeater1.Items[rowIndex].FindControl("txtPayerret");
                TextBox tbCGvesselNum = (TextBox)Repeater1.Items[rowIndex].FindControl("cgaurdNumber");
                TextBox tbCGtaxpayerret = (TextBox)Repeater1.Items[rowIndex].FindControl("cguardreturnedval");
                dtCurrentTable.Rows[i - 1]["boatregNum"] = tbboatregNum.Text;
                dtCurrentTable.Rows[i - 1]["taxpayerret"] = tbPayerret.Text;
                dtCurrentTable.Rows[i - 1]["CGvesselNum"] = tbCGvesselNum.Text;
                dtCurrentTable.Rows[i - 1]["CGtaxpayerret"] = tbCGtaxpayerret.Text;
                rowIndex++;
            }

            if (e.RowIndex < dtCurrentTable.Rows.Count)
            {
                dtCurrentTable.Rows.Remove(dtCurrentTable.Rows[rowID]);
            }
  

Open in new window

0
I am learning ASP.NET Core using somebooks and tutorial, but nearly all of them use a localdb for the database. I would like to create the database into the local Instance of SQLServer Installed on my machine and need help with the syntax for providing the connection string for this purpse.
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
             // This is the connection string I am using currently for mssqllocaldb
             optionsBuilder.UseSqlServer("Server = (localdb)\\mssqllocaldb; Database = BookPost; Trusted_Connection = True; ");
         );
            //  This is the connection string that use I a WPF application to connect to SQLServer intance on my machine
    //< add name = "LibraryEntities" connectionString = "metadata=res://*/Fish.csdl|res://*/Fish.ssdl|res://*/Fish.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=FAHEEMPC\SQLEXPRESS;initial catalog=Library security info=True;user id=sa;password=abcepassword;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName = "System.Data.EntityClient" />

}

Open in new window


Thank you for your help.
0
What does it mean to be "Always On"?
LVL 4
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Hopefully, this is simple.

I have the following GridView loop:

        foreach (GridViewRow row in Gridview1.Rows)
        {
            string registerNumber = (row.FindControl("txtNum") as TextBox).Text;
            if (row.RowIndex == 0)
            {
                this.SetInitialRow2(registerNumber);
            }

            else
            {
                AddNewRow2(registerNumber);
            }
            foreach (RepeaterItem Item in Repeater2.Items)
             {
                  (Item.FindControl("BtnAdd2") as Button).Visible = Repeater2.Items.Count > 1;
                  (Item.FindControl("btnDelete") as Button).Visible = Repeater2.Items.Count > 1;
             }
            }

Open in new window


This works good.

However, I am trying to use same logic but in Repeater but I am stuck on this this line:

        if (Items == 0
...

Open in new window


How do I write this line in Rpeater?

     if (row.RowIndex == 0)

Open in new window


Here is the entire code:

        foreach (RepeaterItem Items in Repeater1.Items)
        {
            string registerNumber = (Items.FindControl("txtNum") as TextBox).Text;
            if (Items == 0)
            {
                this.SetInitialRow2(registerNumber);
            }

            else
            {
                AddNewRow2(registerNumber);
            }
            foreach (RepeaterItem Item in Repeater2.Items)
             {
                  (Item.FindControl("BtnAdd2") as Button).Visible = Repeater2.Items.Count > 1;
                  (Item.FindControl("btnDelete") as Button).Visible = Repeater2.Items.Count > 1;
             }
            }

Open in new window


Thanks in advance
0
So when running this application there is some inline VB code:
<td><asp:Label ID="lblStartTime" runat="server" Text='<%# Convert.ToDateTime(Eval("StartTime")).ToString("hh:mm tt") %>' /></td>

Open in new window

This is where it is crashing and I cannot seem to find out why. The StartTime has a value until it gets to this point and I am getting invalid DateTIme string because the string is empty "". I am out of options and have done a lot of debugging with break points etc.  Then there is a corresponding piece of code:
cb.StartTime = IIf(dr("StartTime") Is DBNull.Value, "", dr("StartTime"))

Open in new window

and for some reason entries from the textboxes are not being pushed to the DB and are set to NULL.
0
I want a seperator in my gridview showing when the value of the column Parti changes.
What im asking for is:
A
A
Seperator
B
B
B
B
Seperator
C

But i get instead
A
A
B
Seperator
B
B
C
Seperator
C

Can you tell me how to fix this?
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {

            if (e.Row.RowType == System.Web.UI.WebControls.DataControlRowType.DataRow)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    DataRowView drv = (DataRowView)e.Row.DataItem;
                    if (previousCat != drv["Parti"].ToString())
                    {
                        Table Tbl = (Table)e.Row.Cells[12].Parent.Parent;
                        GridViewRow Tr = new GridViewRow(12, 12, DataControlRowType.DataRow, DataControlRowState.Normal);
                        Tr.Height = Unit.Parse("10px");
                        Tbl.Controls.Add(Tr);
                    }
                    previousCat = drv["Parti"].ToString();
                }

             }
        }
0
Line 29:                 var test = Convert.ToString(Session["CID"]);
Line 30:                 var sample = Convert.ToString(Session["QPPR"]);
[u]Line 31:                 QUEDT = QUEAdapter.SELECT_QPAPER_BYCID_QPPR(Convert.ToInt32(Session[test]), Session["sample"].ToString());[/u]
Line 32:                 fvquestion.DataSource = QUEDT;
Line 33:                 fvquestion.DataBind();

Open in new window

0
Hi,
I have problem to show Baidu map within this
http://my-friend.co/RegRec2/?id=18&user_abbr=mc2&readonly=y

What to adjust?
0
Hello Experts.  I have a question regarding a formView - Edit template control.  I need to set one of the filed to the name of the user.identy.name when it is edited.  I know all the code behind getting the identity but since I am using the edit template control it will not allow me to set the textbox text to anything.  Is there a way around this?  Thank you
0
Hi,

I have a page that export result from a sp to an excel file, it has been working fine. When I tried to run it today, it gave me the following errors. The only thing I changed was upgraded my VS to 2017. Any ideas?  thanks
Compiler Error Message: CS1705: Assembly 'ClosedXML, Version=0.86.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b' uses 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

Open in new window

0
I have a question already posted about trying to Redirect my app to my Login page after Session_End fires. I have been trying to get around this all day and I was doing some research and found a piece of javascript code that would display a message when the Session timeout interval was complete. I thought I could put this in my Master page Page_Load event and reset the interval everytime its hit, thus restarting the time it would take for the message to display. Im incorrect on this.
What seems to be happening is, when this code gets hit and lets say the interval is 60 seconds. I do another action, lets say 15 seconds later, to cause another Postback and the code to get hit again. I thought that this would restart the interval to another 60 seconds but it wont.  The first call is still in play, meaning after the initial 60 seconds even though I caused another postback, the message would appear. I want the script to somehow reset itself every time it gets hit.
Bottom line is I want to notify the user with an alert that the Session has ended and they will be redirected back to the login screen. This script would be perfect if I can get it to restart or extend the interval every time it gets hit, kinda like with Session. Is it somehow possible for me to cancel the first call and have this one be the only one to run at that point?
I hope this makes sense? I know I write like a caveman.

Here is the code I initially had in a class and would inherit the class on every page…
0
Hi,

I have a quick question. When do you use Chunk and when do you use Phrase in iTextSharp? and when do you use straight  "table.AddCell("something here");"?

thanks
0
Independent Software Vendors: We Want Your Opinion
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

i am trying to make a slide show for an asp.net website. i found examples online but i am having touble getting them to work. does anyone have an example that works. i am tring to use AjaxControlToolkit.Slide but photo are not showing
0
I have a Master page and on it is the user that is logged into the app. I am having trouble assigning a value to this label to the current user. I have a login page that when the user logs in the label on the Master should be updated. I have the label in an Update Panel to refresh everytime the user logs in but it still doesnt take the logged in users value. I have assign a property that I can set the value with from another page  but that isnt working for me? This is the code in the master

    Public Property PageLabel() As String
        Get
            Return lblUser.Text
        End Get
        Set(value As String)
            lblUser.Text = value
            upUserLabel.Update()
        End Set
    End Property

Open in new window

And in my Login page I assign the username after I check the DB with this
Session("LoginLabel") = Session("UserRole") & " \ " & Session("UserName")
 Me.Master.PageLabel = Session("LoginLabel")

Open in new window

I have added this in the Login pages markup
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/ItemMaster.Master" CodeBehind="UserLogin.aspx.vb" Inherits="CRIB_EAST.UserLogin" %>
<%@ MasterType VirtualPath="~/ItemMaster.Master" %>

Open in new window


I know Im screwing up somewhere but I just do not know where.
Any help would be appreciated

Thanks
JK
0
i have an example program to do slides in asp.net and ajax. but the <asp:toolkitscriptmanager> is no longer there. what do i put there for it to work
below is the full code.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Test Slide</title>
    <style>
        .slideTitle
        {
            font-weight: bold;
            font-size: small;
            font-style: italic;
        }

        .slideDescription
        {
            font-size: small;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div style="text-align:center">
               
            <asp:Image ID="Image1" runat="server" Height="355px" ImageAlign="Left" ImageUrl="~/New/pic1.JPG" /><br />    
 <ajaxToolkit:SlideShowExtender ID="SlideShowExtender1" runat="server"
     TargetControlID="Image1"
     SlideShowServiceMethod="GetSlides"
     AutoPlay="true"
     ImageTitleLabelID="imageTitle"
     ImageDescriptionLabelID="imageDescription"
     NextButtonID="nextButton"
     PlayButtonText="Play"
     StopButtonText="Stop"
     PreviousButtonID="prevButton"
     PlayButtonID="playButton"
     Loop="true" />
           
        </div>
    </form>
</body>
</html>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;…
0
Hi,
How to put short text to chart below?
16t.png
that is from

http://my-friend.co/Test_rec4/Default.aspx?userid=mc23
0
How to find out how many files of a specific patterns in a folder

I am using vb in code behind

The following is good to find out the total number of files in a folder  but I need to add the patterns to it - any idea
        Dim counter = My.Computer.FileSystem.GetFiles("D:\FolderName")
        Label1.Text = counter.Count
0
I am trying to redirect my app to my UserLogin.aspx page when Session_End in my Global.asax file gets fired. I call a Public Sub routine in a module that does a Redirect. Bottom line is Im trying to redirect back to login with a querystring that tells me its an error and I will have a message popup but I need it to Redirect first..Any clue what Im doing wrong??

 HttpContext.Current.Response.Redirect("~/UserLogin.aspx?ERROR=SESSIONEND")

Open in new window


Im getting "Object reference not set to an instance of an object." error? Pic below

Thanks for any help!!!
Error
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