Subscribe: Web Forms
Added By: Feedage Forager Feedage Grade B rated
Language: English
cmd parameters  cmd  eval  new  parameters addwithvalue  parameters  runat server  runat  server  string  system  tostring  user 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Web Forms

All Forums

All Forums

Last Build Date: Wed, 17 Jan 2018 12:33:10 -0800


Sql query not work in Listview SelectedIndexChanging



(image) ' />

 protected void IMGLV_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
            ListViewItem item = (ListViewItem)IMGLV.Items[e.NewSelectedIndex];

            Label lb = (Label)item.FindControl("pImageidtxt");
            uPid = lb.Text.ToString();

            cmd = new MySqlCommand("SELECT * FROM pImg WHERE ID=@uPid", cn);
            cmd.Parameters.AddWithValue("@uPid", uPid.ToString());
            dr = cmd.ExecuteReader();
                sURL = dr["URL"].ToString();

            cmd = new MySqlCommand("UPDATE users SET userPhoto = @sURL WHERE ID=@userid", cn);
            cmd.Parameters.AddWithValue("@sURL", sURL.ToString());
            cmd.Parameters.AddWithValue("@userid", userid);

Sql queries work fine in another event, but in the selectedindexchanging event the "sURL" string value is null. Normally, tabloda image URLs are included.

With the link button I click, I can get the index ID without any problems. I just can not get the URL.

SMTP not sending



Is there an obvious reason, please, why the following SMTP code is not working? When the form fields are completed and the 'Send' button pressed, the typed in fields don't even disappear.

The page is here:

The IP address, server port, and passwords are all correct.

Imports System
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Net
Imports System.Net.Mail
Imports System.IO

Public Class Contact
    Inherits System.Web.UI.Page

Private Sub SendEmail_Click(sender As Object, e As System.EventArgs) Handles SendEmail.Click

Dim myMessage As New MailMessage
Dim Smtpserver As New SmtpClient

Dim user_name As String = Request.Form("your_name") 'user_name is the TextBox ID
Dim user_email As String = Request.Form("your_email") 'user_email is the TextBox ID
Dim user_subject As String = Request.Form("your_subject") 'user_subject is the TextBox ID
Dim user_message As String = Request.Form("your_message") 'user_message is the TextBox ID

'Request.Form - extract data from form fields and create the mail message

myMessage.From = New MailAddress(user_email) 'User's email
myMessage.To.Add(New MailAddress("myEmail1@Mail.Com")) 'Webmaster
myMessage.CC.Add(New MailAddress("")) 'Webmaster's assistant
myMessage.Subject = user_subject
myMessage.Body = user_message

myMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
myMessage.IsBodyHtml = True
myMessage.Priority = MailPriority.High

Smtpserver.DeliveryMethod = SmtpDeliveryMethod.Network
Smtpserver.Host = ("IP_add")
Smtpserver.Port = 25
Smtpserver.EnableSsl = False

Dim basicAuthenticationInfo As New 
System.Net.NetworkCredential("", "Pwd")
Smtpserver.Credentials = basicAuthenticationInfo
'Smtpserver.UseDefaultCredentials = False

myMessage = Nothing
Smtpserver = Nothing

pnlFormFields.Visible = False
pnlThankYouMessage.Visible = True

End Sub

End Class


One View, One Form, two controllers



I need some help with this, and I should tell I'm new at this.  It goes this way:

Im using ASP.Net MVC, AdoModel

  • Two Tables: Projects and Engineer
  • One controller for creating a new record of a new project. 

When I want to create a new record(project) I also want to add to it a Engineer (it can be zero, one or many). So, while creating the new record(project), I want to create new records of engineers to the engineering table.

Can somebody help me on this? Please.

Not good at english.

Summary of the problem I am having:

I need to create two records in one form, for two different table.

Error I am receiving:


My code:


datata binding


hello all this is my first post here ...  i have problem with my slideshow i put data list for image and repeater for the video ..... my problem is when i have empty video it show in slide just the img without the video because its empty .pls if u could help me i want to hide the repeater which control the video if empty im using vb 2010 in it inside grid view my code is  :

Please fix this


Here's the original text of my post, typed out in Notepad:


Here's what it looked like when I post it to ASP.NET forums:

(image) in post" width="1264" height="908">

Not my fault. Please fix this.

Here's the post:

How could I access a DropDownList inside a DataList by its UniqueID?


I do have a DropDownList control inside a DataList. When the sqlDataSource that feed the DataList find several records, as many DropDownList Controls are display in the DataList. Let’s say that I click one of the DropDownList and change its value. Since I do not want another DropDownList with the same value on the page how can I change the other DropDownList to a different value if I know its particular UniqueID. This is the way that I’m finding the DropDowList UniqueID in code behind:

'Here we get the clicked ddl unique ID
        ClickedDDLForVoteUniqueID = CType(itemDDL.FindControl("SelectionForVotingDropDownList"), DropDownList).UniqueID.ToString
        Label3.Text = "This is the clicked DDL control Unique ID: " + ClickedDDLForVoteUniqueID

If there is any other way to do things, I will appreciate your suggestions as well. Your code must be in Visual Basic
 Thanks to all.

response sending back NullReferenceException


I'm having an issue returning data from a web API call.
The web API function looks like this:
        public async Task GetProjects()
            var projects = _projectService.GetProjects().ToList();
            return Request.CreateResponse(HttpStatusCode.OK, projects, System.Net.Http.Formatting.JsonMediaTypeFormatter.DefaultMediaType);
The problem is that the results that return say there was a NullReferenceException. I know that the list of projects that's returned is not null or empty. I think it has something to do with the json formatter.
Any suggestions?

Type 'Warning' is not declared


We copied a website and SQL database from a 2008R2 Server to a 2016 Server and are getting the error above on a code page on the new server.  This happened once before and old notes indicate was fixed by adding a reference to Microsoft.ReportViewer.WebForms dll but that was done when it was on the 2008R2 Server and all files and folders of the website were copied to the new 2016 server and web application in IIS.  How can I resolve this issue? Below is code from the module where it is failing.  The error points to the line that says  Dim warnings As Warning() = Nothing Imports System Imports System.IO Imports Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution Imports System.Data.OleDb Imports Microsoft.VisualBasic Imports System.Data Imports System.Drawing Imports System.Drawing.Imaging Public Shared Function CreatePDFReport(ByVal strReportName As String, _ ByVal intRecordID As Int32, _ Optional ByVal intType As Int16 = 1) As String Dim strReturn As String = "" ' Output variables Dim encoding As String Dim mimeType As String Dim extension As String Dim warnings As Warning() = Nothing Dim streamIDs As String() = Nothing ' ReportExecution object prepare Dim rs As New ReportExecutionService() rs.Credentials = System.Net.CredentialCache.DefaultCredentials rs.Url = UtilClass.GetReportServerPath & "/ReportExecution2005.asmx" ' Render arguments Dim result As Byte() = Nothing Dim strFileName As String = "" Dim reportPath As String = "/BodyShopReports/" Dim format As String = "PDF" Dim historyID As String = Nothing Dim devInfo As String = "False" Dim strOutputPath As String = HttpContext.Current.Server.MapPath("~/OfficeDocs/POFiles") ' Prepare report parameters Dim parameters As ParameterValue() Select Case strReportName Case "WorkAuthorization" parameters = New ParameterValue(1) {} parameters(0) = New ParameterValue() parameters(0).Name = "RecordID" parameters(0).Value = intRecordID parameters(1) = New ParameterValue() parameters(1).Name = "ReportType" parameters(1).Value = intType strFileName &= "\WorkAuth" & intRecordID.ToString Case "CustomerBilling" parameters = New ParameterValue(1) {} parameters(0) = New ParameterValue() parameters(0).Name = "RecordID" parameters(0).Value = intRecordID parameters(1) = New ParameterValue() parameters(1).Name = "ReportType" parameters(1).Value = intType strFileName &= "\FinalBill" & intRecordID.ToString Case "TasksAtDropOff" parameters = New ParameterValue(1) {} parameters(0) = New ParameterValue() parameters(0).Name = "RecordID" parameters(0).Value = intRecordID strFileName &= "\TasksAtDropOff" & intRecordID.ToString Case Else End Select Dim strFullPath As String = strOutputPath & strFileName & ".pdf" If File.Exists(strFullPath) Then '1-7-2015 added below to avoid exception error when same file name used Dim strTime As String = [...] Button click event firing twice sometimes


Hello Friends , I have Button a inside gridview some times  Button click event firing twice not every time . Suppose 700 records inserted in data then 50 are repeated. i have checked everything but found nothing  .I don't know why its firing twice or more then that in single click sometime . i have also disabled thru client click but still going same thing . Here is my code: protected void btn_transfer_Click(object sender, EventArgs e){ string user_id="1"; GridViewRow gr = (GridViewRow)((Button)sender).Parent.Parent; TextBox txt_amt = (TextBox)gr.FindControl("txt_Amt_main"); decimal amount_entered = 0; if (decimal.TryParse(txt_amt.Text, out amount_entered)) { amount_entered = Convert.ToDecimal(txt_amt.Text); } amount_entered = amount_entered / 2; decimal cur_val = 15; string id = grd_withdrawal.DataKeys[gr.RowIndex].Values["Id"].ToString(); string incom_per = grd_withdrawal.DataKeys[gr.RowIndex].Values["incom_per"].ToString(); DataTable dt_user_wid_check = d.FillDataTable("SELECT typ FROM bl_r WHERE user_id='" + user_id + "'"); if (dt_user_wid_check.Rows.Count > 0) { d.executenonquery("update User_inc set inc_dis='Paid' where User_inc .id='" + id + "'"); d.messagebox("return msg..", this); fill_grd(); return; } string gid = Guid.NewGuid().ToString(); string query = @" begin tran T1 BEGIN TRY update User_inc set inc_dis='Paid' where User_inc .id='" + id + @"' insert into[tab_wt] (ins_date, user_id, coin_rate, coin_val_dr, coin_val_cr, purchase_from, staus, type, referance)values( dateadd(hh,2, cast(SWITCHOFFSET(TODATETIMEOFFSET(getdate(),'-05:00'),'+05:30') as datetime)), @user_id, @coin_rate, @coin_val_dr, @coin_val_cr, @purchase_from, @staus, @type,@referance) COMMIT TRAN T1; END TRY BEGIN CATCH ROLLBACK TRAN T1 END CATCH "; SqlCommand cmd = new SqlCommand(query, cn); cmd.Parameters.AddWithValue("@user_id",user_id); cmd.Parameters.AddWithValue("@coin_rate", cur_val); cmd.Parameters.AddWithValue("@amt_dr", amount_entered); cmd.Parameters.AddWithValue("@coin_val_dr", "0"); cmd.Parameters.AddWithValue("@coin_val_cr", (amount_entered * cur_val).ToString()); cmd.Parameters.AddWithValue("@purchase_from", "tnvu"); cmd.Parameters.AddWithValue("@staus", "Valid"); cmd.Parameters.AddWithValue("@type", "Purchase"); cmd.Parameters.AddWithValue("@referance", gid); cn.Open(); cmd.CommandTimeout = 1000; int icheck = cmd.ExecuteNonQuery(); cn.Close(); } <%# Container.DataItemIndex+1 %&g[...]

Can we hardcode the date for action link


tell me can we hard code date as route data for action link?

Getting JsonSerializationException


Hello,   I'm having an issue trying to convert an object to json. The error is a Newtonsoft.Json.JsonSerializationException:   Self referencing loop detected for property 'Project' with type 'System.Data.Entity.DynamicProxies.Project_F29F70EF89942F6344C5B0A3A7910EF55268857CD0ECC4A484776B2F4394EF79'. Path '[0].Categories[0]'.   The problem is that the object (it's actually a list of objects) has a property which is another object that refers back to the first object:    public partial class Project { ...     public virtual ICollection Categories { get; set; } ... }   public partial class Category { ...     public virtual Project Project { get; set; } ... }   This is all fine and dandy as far as Entity Framework is concerned, but to convert this to json would result in an infinite regress, hence the exception.   Here is my code:           public async Task GetProjects()         {             var projects = _projectService.GetProjects().ToList();             string jsonString = JsonConvert.SerializeObject(projects); // <-- Offending line             return Request.CreateResponse(HttpStatusCode.OK, jsonString);         }   I've looked online for solutions to this and I found this stackoverflow post:   They suggest three solutions, none of which work:   1) Ignore the circular reference:           public async Task GetProjects()         {             var projects = _projectService.GetProjects().ToList();             JsonSerializerSettings settings = new JsonSerializerSettings()             {                 ReferenceLoopHandling = ReferenceLoopHandling.Ignore             };             string jsonString = JsonConvert.SerializeObject(projects, settings);             return Request.CreateResponse(HttpStatusCode.OK, jsonString);         }   This resulted in the call to SerializeObject(...) hanging for a bit then throwing a  System.OutOfMemoryException (which tells me the circular references were NOT being ignored).   Mind you, the author of this proposed solution at stackoverflow says to set the ignore setting in WebApiConfig.cs but I tried that and it has no effect.   He also says:   "If you want to use this fix in a non-api ASP.NET project, you can add the above line to Global.asax.cs, but first add: var config = GlobalConfiguration.Configuration;"   Mine's a web API with no global file so I shouldn't have to do this.   I also don't want to ignore circular references because I don't want to lose data.   2) Preserve the circular reference:           public async Task GetProjects()         {             var projects = _projectService.GetProjects().ToList();             JsonSerializerSettings settings = new JsonSerializerSettings()             {                 ReferenceLoopHandling = ReferenceLoopHandling.Serialize,                 PreserveReferencesHandling =[...]

This message appears to me :Line 83: SqlDataReader rd = cmd.ExecuteReader();


using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Data; using System.Configuration; public partial class student_usercontrol_examination : System.Web.UI.UserControl {     SqlConnection con;     SqlCommand cmd;     int correct_ans = 0;     int wrong_ans = 0;     int select_no = 0;     int count = 0;     public student_usercontrol_examination()     {         con = new SqlConnection();         con.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();         cmd = new SqlCommand();     }     protected void Page_Load(object sender, EventArgs e)     {         if (!Page.IsPostBack)         {             loadgrid();         }     }     private void loadgrid()     {         con.Open();         cmd.CommandText = "select*from[Question]";         cmd.Connection = con;         SqlDataReader rd = cmd.ExecuteReader();         GridView1.DataSource = rd;         GridView1.DataBind();     }     protected void Button1_Click(object sender, EventArgs e)     {         foreach (GridViewRow row in GridView1.Rows)         {             Label l1 = row.FindControl("QuestionId") as Label;             RadioButton r1 = row.FindControl("ans1") as RadioButton;             RadioButton r2 = row.FindControl("ans2") as RadioButton;             RadioButton r3 = row.FindControl("ans3") as RadioButton;             RadioButton r4 = row.FindControl("ans4") as RadioButton;             if (r1.Checked)             {                 select_no = 1;             }             else if (r2.Checked)             {                 select_no = 2;             }             else if (r3.Checked)             {                 select_no = 3;             }             else if (r4.Checked)             {                 select_no = 4;             }             con.Close();             check_number(l1.Text);         }         Response.Write("correct ans is" + correct_ans.ToString());     }      private void check_number(string text)      {          con.Open();          cmd.CommandText = "select*form[Question] where Question_Id=@qid"+count;          cmd.Parameters.AddWithValue("@qid"+count,text);          cmd.Connect[...]

How to call server side function from @Html.ActionLink


please tell me can we call server side function from @Html.ActionLink ?

@Html.ActionLink("Delete Item", "", new { id = @feedback.Id, q=CallServerSideMethod() }, new { onClick = "confirmDelete("+feedback.Id+");return false;" })

see this area q=CallServerSideMethod() 

looking for suggestion. thanks

Always we need to use partialview when we use @Ajax.ActionLink


@Ajax.ActionLink("Back", "PartialForm",
                      new AjaxOptions
                              UpdateTargetId = "formsIndex", // <-- DOM element ID to update
                              InsertionMode = InsertionMode.Replace, // <-- Replace the content of DOM element
                              HttpMethod = "GET" // <-- HTTP method

i saw when i worked with @Ajax.ActionLink and when i mention action name and when action return view then some html getting copied when new html render. so i search google and found people are saying return partial view from action instead of view. so tell me is it mandatory to use partial view from ajax action link ?

web form 2010 want intellisense when using jquery


I am working with a 2010 web form application that uses jquery. In the original version of the code there were vsdoc files associated with the application so that intellisense worked in Visual Studio.

Now I am in the process of changing the application to use the current version of jquery. When I go to the website to download the latest version of the jquery core library, there is not an option to download a vsdoc.

Thus can you tell me what I can do in visual studio 2010 to have intellisense work when I am accessing the current version of jquery?

web form gridview control concatenate values together in 1 field.


In a 2010 web form application, I have a gridview control that is listed below in the code. In the following line of code: ', '<%# Eval("schoolnum") %>', '<%# Eval("milestone_code") %>', '<%# Eval("stulink") %>', '<%# Eval("HOMELNGCOR") %>', '<%# Eval("semester") %>');" style="color:Blue"><%#Eval("STUDENTNAME")%> , I would like to merge (concantenate) the field values of <%# Eval("HOMELNGCOR") %> with the value of grade that is listed in the gridview control that is listed in the gridview control. I would like the results of the field to be passed in the field called HOMELNGCOR with the value of Grade passed along together in this field. I would like to merge the to fields together since I would not need to rewrite the application. Would you tell me how to accomplish this goal? <%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="default.aspx.vb" Inherits="letters_default" %>
', '<%# Eval("schoolnum") %>', '<%# Eval("milestone_code") %>', '<%# Eval("stulink") %>', '<%# Eval("HOMELNGCOR") %>', '<%# Eval("semester") %>');" style="color:Blue"><%#Eval("STUDENTNAME")%>

How to delete a page if sub report is blank?



I have an ASP.NET application written in C# with the Crystal report. Each page of this report has a header, which always has data, and also a sub report Notes that can be blank. I don't want to show pages that have blank sub report, I need to remove them completely. Without a header this would be pretty simple, but I cannot figure out how to do this in my case.

I'd appreciate your help. Thank you.

check only password


I'm building a backend for an API. I just want to check the password for violations of duty like length or digits with api call. I don't want to change the password. second challenge is that I can't allow asyncrony in the function, because I use fluentvalidation.

Invoking command prompt from MVC using RunAs as different user


I have a MVC application and inside the ActionResult I'm trying to invoke a command prompt but I want to invoke the command prompt using RunAs but it is throwing error.

public static void CommandPromptRunAs(string _commandParameter, string username, string password) { string _output = string.Empty; try { log.Info("Inside CommandPromptRunAs -"); Process cmd = new Process(); cmd.StartInfo.FileName = "cmd.exe"; cmd.StartInfo.RedirectStandardInput = true; cmd.StartInfo.RedirectStandardOutput = true; //cmd.StartInfo.CreateNoWindow = true; cmd.StartInfo.UseShellExecute = false; cmd.StartInfo.Domain = "dir"; cmd.StartInfo.UserName = username; cmd.StartInfo.Password = GetSecureString(password); cmd.StartInfo.WorkingDirectory = @"C:\Windows\System32"; 
cmd.StartInfo.Arguments = @"/c whoami";
cmd.Start(); cmd.StandardInput.WriteLine(_commandParameter.ToString().Trim()); cmd.StandardInput.Flush(); cmd.StandardInput.Close(); //Console.WriteLine(cmd.StandardOutput.ReadToEnd()); cmd.WaitForExit(); var originalConsoleOut = Console.Out; using (var writer = new StringWriter()) { Console.SetOut(writer); Console.WriteLine(cmd.StandardOutput.ReadToEnd()); writer.Flush(); // everything is written out _output = writer.GetStringBuilder().ToString(); log.Info("_output- " + _output.ToString()); } Console.SetOut(originalConsoleOut); ReturnOutput(_output); cmd.Close(); cmd.Dispose(); } catch (Win32Exception w32E) { // The process didn't start. log.Info("error as Win32Exception - " + w32E.StackTrace.ToString()); log.Info("error as Win32Exception - " + w32E.Message.ToString()); //Console.WriteLine(w32E); } catch (Exception ex) { // The process didn't start. log.Info("error as Exception StackTrace -" + ex.StackTrace.ToString()); log.Info("error as Exception Message -" + ex.Message.ToString()); //Console.WriteLine(ex); } } public static SecureString GetSecureString(string str) { SecureString result = new SecureString(); try { if (string.IsNullOrWhiteSpace(str)) return null; else { foreach (char c in str.ToCharArray()) result.AppendChar(c); return result; } } catch (Exception ex) { log.Info("Cannot create password-" + ex.StackTrace.ToString()); } return result; }

But when I'm trying to invoke I'm getting error in the windows event viewer.

Faulting application name: cmd.exe, version: 10.0.14393.0, time stamp: 0x57899a99
Faulting module name: KERNEL32.DLL_unloaded, version: 10.0.14393.1198, time stamp: 0x59028368
Exception code: 0xc0000005
Fault offset: 0x0000000000019bf0
Faulting process id: 0x542c
Faulting application start time: 0x01d3888ec96b977a
Faulting application path: C:\windows\SYSTEM32\cmd.exe
Faulting module path: KERNEL32.DLL
Report Id: d898012b-7838-4f14-9861-24e81c815049
Faulting package full name:
Faulting package-relative application ID: