Using the variable in the code behind

Hi ,

My problem is using the value of a variable from the codebehind page in an html tag.
I have got the html code on default.aspx for example
and there is a variable in default.aspx.vb called THISPAGE.
And in the HTML code I want to use this string value in a form tag like this:

But when I run the page I got an error message that THISPAGE should be declared although I have declared it in the codebehind page.

Posted On: Tuesday 27th of November 2012 10:50:36 PM Total Views:  625
View Complete with Replies

Related Messages:

ascx page ddl control causing postback in holder   (335 Views)
I have an aspx page that contains a pulldown, which, when an item is selected, it adds another control to a panel on the page.This new panel contains 2 dropdowns. When an item from dropdown1 is selected, it causes ddl2 to repopulate with a filtered list (from a sql db). The problem is, when ddl1 is selected, it's causing the main page to do a postback, which is checking for a postback, which clears the panel.How do I get only the control to do a postback
Export to excel using codebehind   (323 Views)
I have an application that I need to export data from a Oracle table to excel. I am writing data to an existing excel template. I was able to do this using OLEDB, however, when I write the data to the spreadsheet it inserts all data as text. How can I do this and keep each fields datatype I have tried excel automation and ADODB, both of which I had issues when I added the refereces needed. I have also tried to set IMEX=0 and IMEX=2 in my connection string below.
Page.IsPostBack Confusing   (325 Views)
,I'm modifying my original code to adapt with new change and now facing a problem... RESET button no long works!At first, I had 2 Sub function: Submit and Reset away from Sub Page_Load and Page.IsPostBack case. But now with some added, I'd have to move Submit function to the If Page.IsPostBack then and somehow the Sub Reset doesn't response anymore. I wonder if it would work again when I somehow move the Reset to the Page.IsPostBack as well. If so, how can I tell which is Submit and which is Reset in that Page.IsPostBack case. I meant they both are IsPostBack, righ
LoginView causing all my objects to not exit   (230 Views)
Hi ,I am trying to get an authentication system on the site I'm doing.I'm using LoginView on each of the two restricted pages to show either the login diaglog or the actual page content.When I encapsulate the actual page code in the and build the page it says that all my controls (used on the code behind page) don't exist in the current context.I'm thinking that this is because the code behind uses these controls but it can't see them when I'm not logged in (because the AnonymousTemplate is showing.Is there a bit of code or control I can use in an if statement to cut out my code behind when the user isn't logged in.BTW, I don't know if this is how most people would do it, the alternative I wanted to do is to have a test on the restricted pages and if the user isn't logged in redirect them to the login page. But I can't find the code or object for such a test - does any one know i
Exporting image to excel using (   (327 Views)
I have looked everywhere and I can't figure out how to export an image to excel. I have know how to export a datagrid to excel but I'm trying to export an image as well. I would appreciate any help.Eric
Getting Table from SQL Server using Datagrid   (298 Views)
Hi Everyone! I have a ASP.NET webform that brings data in from SQL Server 2000 and displays it on a page. I want to update the webpage while in IE using the following code: Dim MyConnection As SqlConnection Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs) MyConnection = New SqlConnection("Data Source=SQLSERVER;Initial Catalog=upsizedCandidate;Integrated Security=True") If Not (IsPostBack) Then BindGrid() End If End Sub Sub MyDataGrid_Edit(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs) MyDataGrid.EditItemIndex = CInt(E.Item.ItemIndex) BindGrid() End Sub Sub MyDataGrid_Cancel(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs) MyDataGrid.EditItemIndex = -1 BindGrid() End Sub Sub MyDataGrid_Update(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs) Dim DS As DataSet Dim MyCommand As SqlCommand Dim UpdateCmd As String = "UPDATE ToddsTable1 SET myNewCol1 = @myNewCol1, myNewCol2 = @myNewCol2" MyCommand = New SqlCommand(UpdateCmd, MyConnection) MyCommand.Parameters.Add(New SqlParameter("@myNewCol1", SqlDbType.NVarChar, 40)) MyCommand.Parameters.Add(New SqlParameter("@myNewCol2", SqlDbType.NVarChar, 20)) MyCommand.Parameters("@Id").Value = MyDataGrid.DataKeys(CInt(E.Item.ItemIndex)) Dim Cols As String() = {"@myNewCol1", "@myNewCol2"} Dim NumCols As Integer = E.Item.Cells.Count Dim I As Integer For I = 2 To NumCols - 2 'skip first, second and last column Dim CurrentTextBox As TextBox CurrentTextBox = E.Item.Cells(I).Controls(0) Dim ColValue As String = CurrentTextBox.Text MyCommand.Parameters(Cols(I - 1)).Value = Server.HtmlEncode(ColValue) Next MyCommand.Connection.Open() Try MyCommand.ExecuteNonQuery() Message.InnerHtml = "Record Updated" & UpdateCmd.ToString() MyDataGrid.EditItemIndex = -1 Catch Exp As SQLException If Exp.Number = 2627 Then Message.InnerHtml = "ERROR: A record already exists with the same primary key" Else Message.InnerHtml = "ERROR: Could not update record, please ensure the fields are correctly filled out" End If Message.Style("color") = "red" End Try MyCommand.Connection.Close() BindGrid() End Sub Sub MyDataGrid_ItemDataBound(ByVal Sender As Object, ByVal E As DataGridItemEventArgs) If (E.Item.ItemType = ListItemType.EditItem) Then Dim i As Integer For i = 0 To E.Item.Controls.Count - 1 If (E.Item.Controls(i).Controls(0).GetType().ToString() = "System.Web.UI.WebControls.TextBox") Then Dim tb As TextBox tb = E.Item.Controls(i).Controls(0) tb.Text = Server.HtmlDecode(tb.Text) End If Next End If End Sub Sub BindGrid() Dim DS As DataSet Dim MyCommand As SqlDataAdapter MyCommand = New SqlDataAdapter("select * from ToddsTable1", MyConnection) DS = New DataSet() MyCommand.Fill(DS, "ToddsTable1") MyDataGrid.DataSource = DS.Tables("ToddsTable1").DefaultView MyDataGrid.DataBind() End Sub Updating ToddsTable1 The table is only 2 columns just to get something working but when I click the edit link my title still shows up but the table disappears. Any thoughts on what I could do differently
cannot view XML input using XSL style sheet   (349 Views)
hello, I am really stuck and not sure what to do...I have just bought a 2.0 book for beginners and upon creating a page and trying to view i get get this message:-Cannot view XML input using XSL style sheet.The XML page cannot be displayed A name was started with an invalid character. Error processing resource 'http://paul/fornext.aspx'. Line 1, Position 2 so I got a copy of Visual Web Developer 2005 Express Edition and write files trhough that but it then opens up a port in order to show my files in a browser window!!Thus I turn for your advice, can you help me resolve this, I am stuck!Thank youPaul Watson
Insert/Update data from DetailsView using SQL view in DataSource   (242 Views)
Hi all,I'm working with VisualStudio2K5 using the VWD interface. What I'm attempting is the following:I have two SQL tables, One containing Vendor info, and one containing lookup information for Vendor Terms. There is a column in Vendor that contains the primary key for the appropriate record in the Vendor Terms table. I have established the appropriate relationship between the two tables in SQL.Now, what I'd like to do on my ASP page, is have a GridView which displays only a few crucial fields from the Vendor table, and then have a DetailsView or FormView that displays the complete information from the Vendor table for whatever record is selected on the GridView, as well as allowing for Inserting, Editing and Deleting within that DetailsView or FormView.So, I've created an SQL datasource for the Gridview pointing to the SQL view of both complete Vendor and VendorTerms tables.Then, I've created a second SQL datasource that grabs the single record that is selected in the Gridview and connected it to the Formview.This is where I run into problems. I would love to be able to edit info in this FormView for existing records, but I obviously want to have the lookup capability when I'm choosing my VendorTerms so I can see the descriptive column from the VendorTerms table in my drop down list rather than the PrimaryKey integer value.I thought I could do this by simply recreating the control in FormView for my VendorTerms as a drop down, doing the appropriate data binding and changing of column visible in the drop down list. This would be great except that my FormView Datasource will not allow me to select the "Update,Insert, etc." check box in the Advanced window of it's properties.Can anybody out there tell me where I'm going wrong and lead me in the right directio
using or php, which is better for search engines?   (303 Views)
, my company is interviewing a person to help us in our organic google listings. Our site is currently programmed using on windows server. The guy that is trying to earn our business claims the following:This info is third hand so please forgive the writer as she doesn't understand that Linux=php and ASP.NET = windows.CODE> 1. Switch our website from an ASP server to a Linux server for several>reasons:> a. Data can be organized so that search engines can spider our site>effectively. Right now that is not the case. For ex: any images we have>on our site prohibit the search engines from finding the keywords around>and after those images. With a Linux server, the search engines won't>even know the images are there. By the way, images don't help us at all>with optimization.> b. The search engines prefer Linux to ASP because they can read them>better and give extra 'points' towards optimization for those websites who>utilize Linux.> c. The style sheets can be separated and allow for spiders to flow>through our entire site easily.> d. ASP does not work well with the Mozilla Firefox browser, a>fairly popular one, and it causes verbage and images to be off kilter and>look sloppy. That won't happen with Linux.> 2. They have stated that the Coding of our site is very poor and outdated,>tags used to code the site by search engines are no longer supported in>the W3C (World Wide Web Consortium), which makes our web pages invalid to>today's standards. In fact they found 233 standard errors on the home>page alone, all of which hurt us in organic optimizationcan anyone confirm thi
Reading multiple recordsets using ExecuteXmlReader()   (298 Views)
This is about XML in .NET 1.x. I'm trying to use multiple recordsets in the same SPROC, calling them via SqlCommand.ExecuteXmlReader(). Is there a way to emulate SqlDataReader.NextResult() to move through each recordset I know that method isn't available in XmlReader.I figure if this doesn't work, I can use a regular tabular recordset with a SqlDataReader and use a XmlTextWriter and construct everything by hand as one big document.
How do I inset text into a panel using codebehind   (226 Views)
Hi I have a panel with a background image and I want to superimpose some text on this using codebehind, how do I do this. I've seen InnerHTML or InnerText and this seems to be what I need. What's the Panel attribute equivelent
Tracking user activity in the DB using cookies and Session() object   (279 Views)
I want to collect user information and activity for each visit in my website. To do so I was thinking in use one cookie to identify user (or machine), this cookie would be permanent in users machine, and use another cookie to identify every session that will be eliminated when user closes the browser or similar.My site has also a private area where users can access previous registration and log in (this private area uses Session() object), but the rest of the site no log in is needed. Then, if user logs in during the visit, I would also store his/her user id in the users session information in the DB. So in the database I would store: -Sessions Table-Session_id (cookie with session number)User_num (if user logs in) Is the user id in the DB for registered users Machine_cookie (permanent cookie that identifies the machine)User_type (Registered or Anonymous) Registered when user logs in during the session, and Anonymous if user doesn t log in IP_addressUser_AgentIs_Carwler (True or False)Browser_name (i.e. IE)Browser_version (i.e. 6.0)Javascript_enabled (True or False)Cookies_enabled (True or False)UrlReferrerIs this a good way to track user activity using cookies in combination with ASP.NET Session() objectMore ideas, suggestionsThank you
Dynamically declare Datagrid using variable?   (239 Views)
Is it at all possible to dynamically create a Datagrid using a variable as it's name I have tried and am either not doing something correct or it cannot be done. Please help. I have tried the following with no success.Private Sub brunTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles brunTest.Click Dim i As Integer Dim strA As String Dim strAi As String strA = "dgDataGrid" For i = 0 To 10 strAi = strA & i Dim strAi as new Datagrid Response.Write(strAi) Response.Write("") Next End Sub
using dynamic dropdownlist   (279 Views)
all,I am trying to create a dynamic dropdownlist in the following codefor (int i=DateTime.Now.Year-90;i Graph using sql data   (358 Views)
HiIm currently creating a graph and the two files that I am using are graph.aspx and graph.ascx as shown below. Currently I am using arrays to state the size and names of the bars however I would like this information to be gained from an sql query. The query is:SELECT OrganisationDetails.Name, SUM(InvoiceDetails.Total) AS TotalFROM InvoiceDetails INNER JOIN InvoiceContents ON InvoiceDetails.OrderID = InvoiceContents.InvoiceID INNER JOIN OrganisationDetails ON InvoiceDetails.OutletID = OrganisationDetails.OrganisationIDGROUP BY OrganisationDetails.Name, InvoiceContents.CompanyIDHAVING (InvoiceContents.CompanyID = 912)ORDER BY OrganisationDetails.NameIs there anyway of incorporating this information to produce the graph so that each record gained from the sql creates a bar and each total = the size of the bar graph.aspx: void Page_Load(Object sender, EventArgs e) { // Declare our variables String [] sItems = new String[10]; Int32 [] iValue = new Int32 [10]; // Populate our variables sItems[0] = "Carrots"; iValue[0] = 23; sItems[1] = "Peas"; iValue[1] = 53; sItems[2] = "Celery"; iValue[2] = 11; sItems[3] = "Onions"; iValue[3] = 21; sItems[4] = "Radishes"; iValue[4] = 43; sItems[5] = "test"; iValue[5] = 43; // Set our axis values dngchart.YAxisValues = iValue; // Set our axis strings dngchart.YAxisItems = sItems; // Provide a title dngchart.ChartTitle = "Inventory Breakdown:"; // Provide an title for the X-Axis dngchart.XAxisTitle = "(units display actual numbers)"; } graph.ascx: private String _sXAxisTitle; private String _sChartTitle; private Int32 _iUserWidth = 300; private String [] _sYAxisItems; private Int32 [] _iYAxisValues; public Int32 UserWidth { get { return _iUserWidth; } set { _iUserWidth = value; } } public Int32 [] YAxisValues { get { return _iYAxisValues; } set { _iYAxisValues = value; } } public String [] YAxisItems { get { return _sYAxisItems; } set { _sYAxisItems = value; } } public String XAxisTitle { get { return _sXAxisTitle; } set { _sXAxisTitle = value; } } public String ChartTitle { get { return _sChartTitle; } set { _sChartTitle = value; } } void Page_Load(Object sender, EventArgs e) { // As long as we have values to display, do so if (_iYAxisValues != null) { // Color array String [] sColor = new String[9]; sColor[0] = "red"; sColor[1] = "lightblue"; sColor[2] = "green"; sColor[3] = "orange"; sColor[4] = "yellow"; sColor[5] = "blue"; sColor[6] = "lightgrey"; sColor[7] = "pink"; sColor[8] = "purple"; // Initialize the color category Int32 iColor = 0; // Display the chart title lblChartTitle.Text = _sChartTitle; // Get the largest value from the available items Int32 iMaxVal = 0; for (int i = 0; i < _iYAxisValues.Length; i++) { if (_iYAxisValues[i] > iMaxVal) iMaxVal = _iYAxisValues[i]; } // Take the user-provided maximum width of the chart, and divide it by the // largest value in our valueset to obtain the modifier Int32 iMod = Math.Abs(_iUserWidth/iMaxVal); // This will be the string holder for our actual bars. String sOut = ""; // Render a bar for each item for (int i = 0; i < _iYAxisValues.Length; i++) { // Only display this item if we have a value to display if (_iYAxisValues[i] > 0) { sOut += "" + _sYAxisItems[i] + ""; sOut += "" + RenderItem(_iYAxisValues[i], iMod, sColor[iColor]) + ""; iColor++; // If we have reached the end of our color array, start over if (iColor > 8) iColor = 0; } } // Place the rendered string in the appropriate label lblItems.Text = sOut; // Drop in the Y Axis label lblXAxisTitle.Text = _sXAxisTitle; } } //**************************************************************************************** // Graph.RenderItem Method // // // Generates a horizontal bar graph for a given item //**************************************************************************************** private String RenderItem (Int32 iVal, Int32 iMod, String sColor) { String sRet = ""; sRet += ""; sRet += ""; sRet += "" + iVal + ""; sRet += ""; return sRet; }
Send HTML email using URL as source   (332 Views)
I want to be able to send an HTML email from with my ASP.NET code using System.Web.Mail where a URL is specified for the email content. Anyone know how
Passing Values using tag in HTML Code   (214 Views)
hey ,I am using this Code in HTML Page to display all the Name from the Dataset CODE Now u can see the checkboxes are created at the run-time as per the rows in the dataset and each is having the same id "CheckBox3"Now in the Code Window... at time of CheckBox3_CheckedChanged event i want to know which row is checked....Please help me..i feel like i am in hell.... be'se don't find any solution
using a crystal report with a dataset   (291 Views)
Check out this thread:thread855-1123137Jim
anyone using 2.0 beta 2 yet?   (247 Views) 2.0 has the neat little thing now where you can populate a gridview based on grabbing info from a query string. Here's my question. I have a gridview in a webpart that is displaying a small amount of info on our purchase orders. I want the user to be able to click on an item, which will transfer them to another page for complete details. I want to send the datakeyfield from the first gridview in a querystring to the second page. I know how to do this on code, but I was just curious if there is a GUI way to do it in 2.0. I have a hyperlink templated column in the first gridview and I have my navigateurl property setup to like details.aspx{0} - i thought that was how to do it, but I need to connect the datakeyfield with the {0}...
sending e-mails with or without attachments using aspx   (226 Views)
Below is the code used to allow users to send e-mails. Now I need to modifiy the code to allow users the ability to send emails with or without attachments. How do I do this Sub buttonSend_Click(sender As Object, e As EventArgs) Dim emailMessage As MailMessage emailMessage = New MailMessage emailMessage.From = textEmail.Text emailMessage.To = textTo.Text emailMessage.Subject = textSubject.Text emailMessage.Body = "Department: " & textDept.Text & vbcrlf & vbcrlf & "Name: " & textName.Text & vbcrlf & vbcrlf & "Url: " & textUrl.Text & vbcrlf & vbcrlf & "Message: " & textMessage.Text SmtpMail.SmtpServer="cfmsvr1254" Try SmtpMail.Send(emailMessage) labelStatus.Text = "Thank You!" buttonSend.Enabled = False Catch ex As Exception labelStatus.Text = "Unable to send e-mail message." End Try End Sub Sub buttonNewMessage_Click(sender As Object, e As EventArgs) textEmail.Text = "" textSubject.Text = "" textDept.Text = "" textName.Text = "" textUrl.Text = "" textMessage.Text = "" buttonSend.Enabled = True labelStatus.Text = "" End Sub