|
Something like this should work:
ToolTip='<%# RecordingExists(Eval("filename", "{0}"), Eval("servername", "{0}")) ? "Play recording" : "No audio exists for this record" %>'
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I am getting two errors.
One said The '?' character cannot be used here.
The other error says: syntax error on -> "No audio exists for this record"
|
|
|
|
|
Are you using VB.NET? If so, try:
ToolTip='<%# If(RecordingExists(Eval("filename", "{0}"), Eval("servername", "{0}")), "Play recording", "No audio exists for this record") %>'
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sorry sir, since you presented the code in c# the first time, I didn't want to trouble you with converting to VB. I was doing that instead.
I didn't think it mattered in this last code since it is markup.
Everything is working like we want it.
I am truly grateful.
THANK YOU
|
|
|
|
|
I am trying to deploy my aspnet core application in IIS, and followed the guidelines provided in this [URL]as well as in this[Host ASP.NET Core on Windows with IIS].
When I checked the Eventviewer in the Prod Server, I am getting the error message in Application logs as "Quote: Application 'MACHINE/WEBROOT/APPHOST/TestAppCore20' with physical root 'E:\TestAppCore20\' failed to start process with commandline '%LAUNCHER_PATH% .\TestAppCore20.dll', ErrorCode = '0x80070002' : 0. .
While googling for the above resolution, I foundout one solution [here], but again the same status. Please anybody can have a look and help please?
My web.config is as follows:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore requestTimeout="02:00:00"
processPath="%LAUNCHER_PATH%"
arguments=".\TestAppCore20.dll"
stdoutLogEnabled="true"
stdoutLogFile=".\logs\stdout"
forwardWindowsAuthToken="false"
/>
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 97cf335d-efd6-4064-bca2-7a4901141162-->
|
|
|
|
|
The issue was resolved. The issue was with the Web.config. Web.config should be similar as below once deployed to server:
<pre>="1.0"="utf-8"
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,DELETE,PUT" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" responseBufferLimit="0" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\yourappName.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
<modules runAllManagedModulesForAllRequests="false">
<remove name="WebDAVModule" />
</modules>
</system.webServer>
</location>
</configuration>
|
|
|
|
|
using elliptic curve cryptography hoe to encrypt and decrypt a text
|
|
|
|
|
|
How to import rows from Excel to MS SQL using ASP.net (VB code)?
|
|
|
|
|
|
Greetings again.
Hope this won't be too much of a bother.
I have the following from my gridview:
sp:HyperLinkField DataNavigateUrlFields="filename" headertext="Recording" DataNavigateUrlFormatString="http://Archive/{servername from DB}/play_recording_wav.asp.net?filename='noop_'{0}'.wav" Text="Listen" />
When run, I would like it the url to look like this:
http:
Basically, server1 is value for fieldname called servername, noop_ is hardcoded to filename which is also from the database.
More like this:
c = "archives/"+ '<%# Eval("Servername") %> + "noop_" + Eval("filename") %>' + ".wav"
modified 23-May-19 15:29pm.
|
|
|
|
|
Try:
<asp:HyperLinkField
DataNavigateUrlFields="filename, servername"
DataNavigateUrlFormatString="http://Archive/{1}/play_recording_wav.aspx?filename=noop_{0}.wav"
...
/>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you very much sir.
I really appreciate your help.
|
|
|
|
|
when i saved bookmarks i need to force the user to sign in instead of continuing with the application for safety and security. can you please share the code that i can use.
|
|
|
|
|
Its hard to predict in my knowledge to check if user accessing your application from bookmark link. Also, are you not killing your active sessions? So when user bookmark your application link and comes back after some time/day that session is gone and he has to re-login again? What is your strategy to establish session with user on login?
modified 20-Sep-20 21:01pm.
|
|
|
|
|
Sir
I am using VB.Net 2008 and i want to creat user registration page where i want to send user confirmation OTP via email during the user registration.please guide me with code using vb.net 2008 in developing asp web.
|
|
|
|
|
|
|
Hi, I am using Visual Studio Community 2017 and i created a table called Workstations
with my .cs code i am traing to insert data into the table. I am also struggling to add the dateTimePicker into the Purch_Date and WExpiry_Date fields. i am receive this error when doing a debug on the script "
Cannot insert the value NULL into column 'Status_Id', table 'ITInventory.dbo.Workstations'; column does not allow nulls. INSERT fails. "below is my code. Hope someone can help me with this. Thank you in advance
.cs code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Configuration;
namespace InventoryStock
{
public partial class Workstations : Form
{
public object WExpiry_Date { get; private set; }
public Workstations()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label1_Click_1(object sender, EventArgs e)
{
}
private void Workstations_Load(object sender, EventArgs e)
{
this.workstationsTableAdapter.Fill(this.iTInventoryDataSet.Workstations);
comboBox3.SelectedIndex = 0;
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=sh-jasonk\dev;Initial Catalog=ITInventory;Integrated Security=True");
con.Open();
bool Wkst_Status = false;
if (comboBox3.SelectedIndex == 0)
{
Wkst_Status = true;
}
else
{
Wkst_Status = false;
}
SqlCommand cmd = new SqlCommand
(@"INSERT INTO [dbo].[Workstations]
(
[Emp_Name]
,[Emp_Surname]
,[Department]
,[Company]
,[Hostname]
,[Wkst_Status]
,[Make]
,[Model]
,[SerialNumber]
,[ProductNumber]
,[Purch_Date]
,[WExpiry_Date]
,[Memory]
,[Processor]
,[HDD]
,[OS])
VALUES
('" + txtName.Text + "','" + txtSurname.Text + "','" + comboBox1.Text + "','" + comboBox2.Text + "','" + txtHostName.Text + "','" + comboBox3.SelectedIndex + "','" + txtMake.Text + "','" + txtModel.Text + "','" + txtSN.Text + "','" + txtPN.Text + "','" + dateTimePicker1.Value.ToString("yyyy/MM/dd") + "','" + dateTimePicker1.Value.ToString("yyyy/MM/dd") + "','" + txtMem.Text + "','" + txtProc.Text + "','" + txtHDD.Text + "','" + txtOS.Text + "')",con);
cmd.ExecuteNonQuery();
con.Close();
SqlDataAdapter sda = new SqlDataAdapter(@"Select [Emp_Name][Emp_Surname],[Department],[Company],[Hostname],[Wkst_Status],[Make],[Model]
,[SerialNumber],[ProductNumber],[Purch_Date],[WExpiry_Date],[Memory],[Processor],[HDD]
,[OS] From [dbo].[Workstations]", con);
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridView1.Rows.Clear();
foreach (DataRow item in dt.Rows)
{
int n = dataGridView1.Rows.Add();
dataGridView1.Rows[n].Cells[0].Value = item["Emp_Name"].ToString();
dataGridView1.Rows[n].Cells[1].Value = item["Emp_Surname"].ToString();
dataGridView1.Rows[n].Cells[2].Value = item["Department"].ToString();
dataGridView1.Rows[n].Cells[3].Value = item["Company"].ToString();
dataGridView1.Rows[n].Cells[4].Value = item["Hostname"].ToString();
if ((bool)item["Wkst_Status"])
{
dataGridView1.Rows[n].Cells[5].Value = "Active";
}
else
{
dataGridView1.Rows[n].Cells[5].Value = "Inactive";
}
dataGridView1.Rows[n].Cells[6].Value = item["Make"].ToString();
dataGridView1.Rows[n].Cells[7].Value = item["Model"].ToString();
dataGridView1.Rows[n].Cells[8].Value = item["SerialNumber"].ToString();
dataGridView1.Rows[n].Cells[9].Value = item["ProductNumber"].ToString();
dataGridView1.Rows[n].Cells[10].Value = item["Purch_Date"].ToString();
dataGridView1.Rows[n].Cells[11].Value = item["WExpiry_Date"].ToString();
dataGridView1.Rows[n].Cells[12].Value = item["Memory"].ToString();
dataGridView1.Rows[n].Cells[13].Value = item["Processor"].ToString();
dataGridView1.Rows[n].Cells[14].Value = item["HDD"].ToString();
dataGridView1.Rows[n].Cells[15].Value = item["OS"].ToString();
}
}
private void label17_Click(object sender, EventArgs e)
{
}
}
}
my SQL table create code
USE [ITInventory]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Workstations](
[Emp_Id] [int] IDENTITY(1,1) NOT NULL,
[Emp_Name] [varchar](30) NOT NULL,
[Emp_Surname] [varchar](30) NOT NULL,
[Department] [varchar](50) NOT NULL,
[Company] [varchar](30) NOT NULL,
[Hostname] [nvarchar](20) NOT NULL,
[Wkst_Status] [varchar](15) NOT NULL,
[Make] [varchar](12) NOT NULL,
[Model] [varchar](15) NOT NULL,
[SerialNumber] [nvarchar](30) NOT NULL,
[ProductNumber] [nvarchar](30) NOT NULL,
[Purch_Date] [date] NOT NULL,
[WExpiry_Date] [date] NOT NULL,
[Memory] [nvarchar](6) NOT NULL,
[Processor] [nvarchar](10) NOT NULL,
[HDD] [nvarchar](10) NOT NULL,
[OS] [nvarchar](25) NOT NULL,
[Status_Id] [int] NOT NULL,
CONSTRAINT [PK__Workstat__262359ABF6F5A9AA] PRIMARY KEY CLUSTERED
(
[Emp_Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Workstations] WITH CHECK ADD CONSTRAINT [FK__Workstati__Statu__6FE99F9F] FOREIGN KEY([Status_Id])
REFERENCES [dbo].[Status] ([Status_Id])
GO
ALTER TABLE [dbo].[Workstations] CHECK CONSTRAINT [FK__Workstati__Statu__6FE99F9F]
GO
|
|
|
|
|
Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^]
How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]
Query Parameterization Cheat Sheet | OWASP[^]
using (SqlConnection con = new SqlConnection(@"Data Source=sh-jasonk\dev;Initial Catalog=ITInventory;Integrated Security=True"))
using (SqlCommand cmd = new SqlCommand(@"INSERT INTO [dbo].[Workstations]
(
[Emp_Name],
[Emp_Surname],
[Department],
[Company],
[Hostname],
[Wkst_Status],
[Make],
[Model],
[SerialNumber],
[ProductNumber],
[Purch_Date],
[WExpiry_Date],
[Memory],
[Processor],
[HDD],
[OS]
)
VALUES
(
@Emp_Name,
@Emp_Surname,
@Department,
@Company,
@Hostname,
@Wkst_Status,
@Make,
@Model,
@SerialNumber,
@ProductNumber,
@Purch_Date,
@WExpiry_Date,
@Memory,
@Processor,
@HDD,
@OS
)", con))
{
cmd.Parameters.AddWithValue("@Emp_Name", txtName.Text);
cmd.Parameters.AddWithValue("@Emp_Surname", txtSurname.Text);
cmd.Parameters.AddWithValue("@Department", comboBox1.Text);
cmd.Parameters.AddWithValue("@Company", comboBox2.Text);
cmd.Parameters.AddWithValue("@Hostname", txtHostName.Text);
cmd.Parameters.AddWithValue("@Wkst_Status", comboBox3.SelectedIndex);
cmd.Parameters.AddWithValue("@Make", txtMake.Text);
cmd.Parameters.AddWithValue("@Model", txtModel.Text);
cmd.Parameters.AddWithValue("@SerialNumber", txtSN.Text);
cmd.Parameters.AddWithValue("@ProductNumber", txtPN.Text);
cmd.Parameters.AddWithValue("@Purch_Date", dateTimePicker1.Value);
cmd.Parameters.AddWithValue("@WExpiry_Date", dateTimePicker1.Value);
cmd.Parameters.AddWithValue("@Memory", txtMem.Text);
cmd.Parameters.AddWithValue("@Processor", txtProc.Text);
cmd.Parameters.AddWithValue("@HDD", txtHDD.Text);
cmd.Parameters.AddWithValue("@OS", txtOS.Text);
con.Open();
cmd.ExecuteNonQuery();
}
Now it should be obvious what the problem is: you're not specifying a value for the required Status_Id column.
NB: Rather than hard-coding your connection string, look at storing it in the application configuration file instead:
Connection Strings and Configuration Files | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello
I'm using the Ajax ToolKit File Upload
I upload very well the files of Word, Excel, txt, jpg, PNG, XML, zip....
But AutoCAD files type dwg, IPT, stp ….. the Ajax ToolKit File Upload CAN NOT upload …. only mark ERROR when you click the UPLOAD button.
The size of AutoCAD files is small from 150kb to 300kb
Because these types of DWG files cannot be loaded ????
This is my HTML Codigi and this is the Web. Config
<pre>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="styles.css" rel="stylesheet" type="text/css" media="screen"/>
</head>
<body>
<form id="form1" runat="server">
<asp:scriptmanager runat="server"></asp:scriptmanager>
<div>
<ajaxToolkit:AjaxFileUpload
ID="AjaxFileUpload1"
runat="server"
OnUploadComplete="AjaxFileUpload1_UploadComplete"
OnUploadCompleteAll="AjaxFileUpload1_UploadCompleteAll"
Mode="Auto"
ChunkSize="4096"
MaxFileSize="21000000" />
</div>
</form>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http:
-->
<configuration>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<httpRuntime maxRequestLength="20480" targetFramework="4.5" />
<httpHandlers>
<add verb="*"
path="AjaxFileUploadHandler.axd"
type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit, Version=4.5.7.725, Culture=neutral, PublicKeyToken=28F01B0E84B6D53E"
/>
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="AjaxFileUploadHandler"
verb="*"
path="AjaxFileUploadHandler.axd"
type="AjaxControlToolkit.AjaxFileUploadHandler,AjaxControlToolkit"/>
</handlers>
<defaultDocument>
<files>
<clear />
<add value="Default.aspx" />
<add value="LoginP.aspx" />
<add value="LoginA.aspx" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
|
|
|
|
|
There's nothing in the code you've shown which would restrict the types of file that could be uploaded. Assuming the files are not larger than the maximum file size, the problem is most likely in your code-behind.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
In a vb.net 2012 web form application, there is a page that is only accessed by the administrators of the application.
There are 2 drop down list options for the user to select and one submit button. Basically one drop donw list is the language that
is to be selected and the kind of letter that is to be generated. The letter is a 'template' generic letter that the administrator changes.
After the administrator hits the submit button, the template letter is changed in the database and one dropdown list shows the language that
was selected. The problem is the kind of letter drop list does not stay and show what was selcted. The kind of letter drop down lists displays
what the intitial drop down list looked like initially.
Thus would you show me how to keep is the kind of letter drop down list from changing once the user clicks the submit button?
|
|
|
|
|
It looks like you reloaded the control binding on post back event happen when submit button hits. Check on how you binding the data to these controls on page_load event.
modified 20-Sep-20 21:01pm.
|
|
|
|
|
Hello
I am working my way through Microsoft's WebFormsIdentity template. In the template, the login.aspx page has this:
<pre>Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
RegisterHyperLink.NavigateUrl = "Register"
OpenAuthLogin.ReturnUrl = Request.QueryString("ReturnUrl")
Dim returnUrl = HttpUtility.UrlEncode(Request.QueryString("ReturnUrl"))
If Not [String].IsNullOrEmpty(returnUrl) Then
RegisterHyperLink.NavigateUrl += "?ReturnUrl=" & returnUrl
End If
End Sub
Protected Sub LogIn(sender As Object, e As EventArgs)
If IsValid Then
Dim manager = Context.GetOwinContext().GetUserManager(Of ApplicationUserManager)()
Dim signinManager = Context.GetOwinContext().GetUserManager(Of ApplicationSignInManager)()
Dim result = signinManager.PasswordSignIn(Email.Text, Password.Text, RememberMe.Checked, shouldLockout:=False)
Select Case result
Case SignInStatus.Success
IdentityHelper.RedirectToReturnUrl(Request.QueryString("ReturnUrl"), Response)
Exit Select
Case SignInStatus.LockedOut
Response.Redirect("/Account/Lockout")
Exit Select
Case SignInStatus.RequiresVerification
Response.Redirect(String.Format("/Account/TwoFactorAuthenticationSignIn?ReturnUrl={0}&RememberMe={1}",
Request.QueryString("ReturnUrl"),
RememberMe.Checked),
True)
Exit Select
Case Else
FailureText.Text = "Invalid login attempt"
ErrorMessage.Visible = True
Exit Select
End Select
End If
End Sub
End Class
In that second Protected Sub under Select Case, can I comment out this line
IdentityHelper.RedirectToReturnUrl(Request.QueryString("ReturnUrl"), Response)
to redirect the user instead to my userpage.aspx page, something like
Response.Redirect("Userpage.aspx")
Thanks!
|
|
|
|
|