Subscribe: Web Forms
http://forums.asp.net/rss.aspx?ForumID=18
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
alert script  alert  btnsave gettype  col col  col  gettype alert  new  project  script alert  script lblmessage  script  string  text 
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: Sat, 23 Sep 2017 04:00:09 -0700

 



Please i want to clear my txtbox and dropdown after submitting data

2017-09-23T10:01:20.78-07:00

Please i want to clear my txtbox and dropdown after submitting data

protected void btnSave_Click(object sender, EventArgs e) { lblMessage2.Visible = false; if (txtname.Text == "") { // MessageBox1.ShowError("Enter Date Please"); ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "", false); } else { lblMessage2.Text = ""; if (ddlpaymentmethod.SelectedIndex < 1) { ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "", false); } else { lblMessage2.Text = ""; if (ddlorderstatus.SelectedIndex < 1) { ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "", false); } else { lblMessage2.Text = ""; if (txtcustomerqty.Text == "") { // MessageBox1.ShowError("Enter Date Please"); ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "", false); } else { lblMessage2.Text = ""; if (txtunitprice.Text == "") { // MessageBox1.ShowError("Enter Date Please"); ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "", false); } else { lblMessage2.Text = ""; [...]



How do i clear dropdown and textbox after submition

2017-09-23T09:58:39.57-07:00

Please i want to clear my txtbox and dropdown after submitting data protected void btnSave_Click(object sender, EventArgs e) { lblMessage2.Visible = false; if (txtname.Text == "") { // MessageBox1.ShowError("Enter Date Please"); ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "", false); } else { lblMessage2.Text = ""; if (ddlpaymentmethod.SelectedIndex < 1) { ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "", false); } else { lblMessage2.Text = ""; if (ddlorderstatus.SelectedIndex < 1) { ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "", false); } else { lblMessage2.Text = ""; if (txtcustomerqty.Text == "") { // MessageBox1.ShowError("Enter Date Please"); ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "", false); } else { lblMessage2.Text = ""; if (txtunitprice.Text == "") { // MessageBox1.ShowError("Enter Date Please"); ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "", false); } else { lblMessage2.Text = "";

<[...]




Insert 'group' uniqueidentifier

2017-09-23T08:52:06.61-07:00

Hey,

I need to retro-insert a uniqueidentifier, but rather than each row having a unique one, I need groups of them.  For example:

[img]https://i.imgur.com/Y0ECNY9.png[/img]

https://imgur.com/Y0ECNY9

So where rows have the same date and similar time (within a few minutes) I need them to have the same value.

Thanks!




http Handlers

2017-09-22T15:38:12.723-07:00

Hey,

I have a http handler that downloads files.  This works well when it's called from a link.

But I have a case where I need error/success pages to be shown.  When error, show the error id and message.  When success show a success result as well as execute the download handler.

This is what I'm using, but response.redirect obviously redirects away from the landing page, offers the file download in the browser and leaves a blank page open.

switch (StatusId) {

	case 0:
	
		HeaderMsg = "Success";
		Response.Redirect("~/download.ashx?DocumentId=" + DocumentId);
		break;
		
	case 1:
	case 2:
	
		HeaderMsg = "Error";
		Assist_Label.Visible = true;
		break;
		
	default:
	
		break;
		
}

Whole code for default.aspx.cs.  We send links in emails pointing to https://domain/default.aspx?DocumentId=xxxx

using System;
using System.Data;
using System.Data.SqlClient;
using System.Net;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class _Default : Page
{

	private SqlConnection Connection;
	private SqlCommand Command;
	private SqlDataReader dr;
	private Guid DocumentId;
	private string SqlConnection = WebConfigurationManager.ConnectionStrings["SqlConn"].ToString();
	private string HeaderMsg, StatusMsg;
	private int StatusId;

	private void Page_Init(object sender, EventArgs e)
	{

		
		
	}
	
	private void Page_Load(object sender, EventArgs e)
	{
	
		DocumentId = Guid.Parse(Request["DocumentId"]);
		
		using (Connection = new SqlConnection(SqlConnection))
		using (Command = new SqlCommand("dbo.ef_sp_GetRemoteDoc", Connection))
		{
		
			Command.CommandType = CommandType.StoredProcedure;			
			Command.Parameters.AddWithValue("@DocumentId", DocumentId);
			
			Connection.Open();
			using (dr = Command.ExecuteReader())
			{
			
				if (dr.HasRows)
				{
				
					while (dr.Read())
					{
					
						StatusId = (int)dr["StatusId"];
						StatusMsg = (string)dr["StatusMsg"];
						
					}
					
				}
				
			}
			
		}
		
		switch (StatusId) {
		
			case 0:
			
				HeaderMsg = "Success";
				Response.Redirect("~/download.ashx?DocumentId=" + DocumentId);
				break;
				
			case 1:
			case 2:
			
				HeaderMsg = "Error";
				Assist_Label.Visible = true;
				break;
				
			default:
			
				break;
				
		}
		
		Header_Label.Text = HeaderMsg;
		Detail_Label.Text = StatusMsg;
		Assist_Label.Text = "Please contact your  representative for assistance.";
		
	}
	
}

Thanks




Other messageboards for .net core?

2017-09-23T07:41:48.71-07:00

Hi, I've been using this bord alot for asking questions. But sometimes I would like to just discuss things or read about experiences and ideas from people interested in .net core. I feel these message bords, as well as stack overflow, is not suitable for that. It probably has something to do with the incentive to reward answers and thus we get an atmosphere that is very streamlined to asking and recieving, and this is not always ideal for me.

I can't seem to find any good messageboards for programming or .net. All messageboards like this or at  dreamincode.net are all too chaotic and have too many subforums. This is not a good way to stimulate conversations and debate. I feel such forums must be made with more social intelligence and incentives should reflect that.  Because if incentive is just to get a reward to answer a question, the answer is more often times short and both answer and question is hurt by this. Another thing is that if users see that the questiong thread has been marked as answered, people think the thread is over. Changing from marking answers to "likes" would go some way to remedy this.

We need to find a better way for making discussion boards for .net. I can't stress how important this is for creating and maintaining a vibrant community. Yet I see little effort of doing so. Isn't that strange, or is it just me who can't find the communities that exist? It should be easy for Microsoft to take the incentive to do this. I would be more than happy to contribute.

The nature of any "nerd" message board that i've seen has this main problem: Everything gets reduced to smaller components. Then you get rules that is set to maintain this. You start with some general categories, like "asp.net", "c#". Then someone is annoyed because some people asks questions that does not fit well into those categories. So they create some more categories, like "Sql" and "html, css and javascript". Then this continues untill there are too many categories. Furthermore, this creates precedence in how to make new posts too, so now you must ask questions in a specific way, and they must all be questions. 

There are more tendencies and concequences than these(but i wont write a book about it).  




Please help me convert this to lambda

2017-09-21T22:20:59.817-07:00

var Prjcts = from p in db.projects
join pc in db.projects_categories on p.ID equals pc.PID
join c in db.departments_categories on pc.CID equals c.ID
join ps in db.projects_sites on p.ID equals ps.PID
join s in db.sites on ps.SID equals s.ID
join pst in db.projects_status on p.ID equals pst.PID
join t in db.status on pst.SID equals t.ID
join u in db.users on p.LID equals u.ID
join pm in db.users on p.PMID equals pm.ID
join prp in db.projects_products on p.ID equals prp.PID
join pr in db.products on prp.PRDID equals pr.ID
join pg in db.projects_groups on p.ID equals pg.PID
join g in db.departments_groups on pg.GID equals g.ID
where p.DID == myDID

I've spent a lot of time spinning my wheels... especially when there's an XREF table requiring three tables to be joined.

Lastly, once the three table joins are complete, please let me know how to output the result.  I think I'm close to getting the three table join down, but then I can't figure out how to write it to Output... The option simply isn't there.  It is for the simple two table joins however.

Thank you!




SignInManager.GetExternalLoginInfoAsync returns null

2017-09-23T07:23:22.8-07:00

SignInManager.GetExternalLoginInfoAsync returns null. I am not sure why. I am trying to retrieve the same "userId" (user-defined) that I stored in the cache via "OnAuthorizationCodeReceived": public async Task OnAuthorizationCodeReceived(AuthorizationCodeReceivedContext context) { // string userId = context.Ticket.Principal.FindFirst(ClaimTypes.NameIdentifier).Value; // string userId = context.HttpContext.User.Identity.Name; string userId = context.Principal. FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; // Use MSAL to swap the code for an access token // Extract the code from the response notification string code = context.ProtocolMessage.Code; TokenCache tokenCache = new SessionTokenCache(userId, context.HttpContext).GetMsalCacheInstance(); ClientCredential clientCred = new ClientCredential(azureadclientsecret); ConfidentialClientApplication cca = new ConfidentialClientApplication(azureadclientid, string.Format(CultureInfo.InvariantCulture, azureadaadinstance, "common", "/v2.0"), oauth2redirecturi, clientCred, tokenCache, null); try { AuthenticationResult result = await cca.AcquireTokenByAuthorizationCodeAsync(code, oauth2appscopes.Split(' ')); context.HandleCodeRedemption(result.AccessToken, result.IdToken); } catch { AuthenticationResult result = await cca.AcquireTokenSilentAsync(oauth2appscopes.Split(' '), cca.Users.First()); // throw; } } In the following task where the app gets the access token, SignInManager.GetExternalLoginInfoAsync returns null (need to get the "ExternalLoginInfo", so that I can get the "userId" (user-defined) from it): public async Task GetAccessToken() { string accessToken = null; // Load the app config from web.config string appId = _oauth2.AppId; string appPassword = _oauth2.AppPassword; string redirectUri = _oauth2.RedirectUri; string[] appScopes = _oauth2.AppScopes .Replace(' ', ',').Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); ExternalLoginInfo info = await _signInManager.GetExternalLoginInfoAsync(/*userId*/); // ClaimsPrincipal principal = User as ClaimsPrincipal; // ClaimsIdentity principalIdentity = principal.Identity as ClaimsIdentity; string userId = info.Principal.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; // Get the current user's ID // string userId = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; // string userId = principalIdentity.FindFirst(ClaimTypes.NameIdentifier).Value; // string userId = principal.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; if (!string.IsNullOrEmpty(userId)) { // Get the user's token cache Microsoft.Identity.Client.TokenCache tokenCache = new SessionTokenCache(userId, HttpContext).GetMsalCacheInstance(); // Microsoft.Identity.Client.TokenCache tokenCache = new NaiveSessionCache(userId, HttpContext.Session); ConfidentialClientApplication cca = new ConfidentialClientApplication( appId, redirectUri, new Microsoft.Identity.Client.ClientCredential(appPassword), tokenCache, null); Microsoft.Identity[...]



Get IN/OUT Records

2017-09-23T07:21:10.187-07:00

Hi,

I have a table with some data like,

Name               DateTime

John                 1/1/2017  8:45am ---In

John                 1/1/2017  10:00am ---Out

John                 1/1/2017   15:00pm ----In

Andrew             1/1/2017   9:00am ---In

Samantha          1/1/2017   9:15am ---In

Andrew              1/1/2017   15:30pm --Out

Samantha           1/1/2017   18:00pm --Out

Based on the above records, i wish to separate the IN and OUT rows and insert into a temp table like this,

                        Odd                                     Even

John               1/1/2017   8:45am                 1/1/2017  10:00am

John               1/1/2017   15:00pm                NULL

Andrew           1/1/2017   9:00am                 15:30pm

Samantha        1/1/2017   9:15am                 18:00pm

How can I achieve this using a simple ms sql query

Thanks

hahsm 




HTTP Error 500 when loading ~\Content\css

2017-09-20T14:19:10.84-07:00

Hi! I have a kind of standard MVC web application built with VS Express 2013. My BundleConfig.cs is like this: using System.Web; using System.Web.Optimization; namespace AcompOrcEst.UI { public class BundleConfig { // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862 public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}")); bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( "~/Scripts/jquery.validate*")); // Use the development version of Modernizr to develop with and learn from. Then, when you're // ready for production, use the build tool at http://modernizr.com to pick only the tests you need. bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( "~/Scripts/modernizr-*")); bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( "~/Scripts/bootstrap", "~/Scripts/respond")); bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/bootstrap.flatly.min.css", "~/Content/Site.css")); } } } I'm using this bootstrap.css alternative theme, bootstrap.flatly.min.css. The section of my _Layout.cshtml is like this: @ViewBag.Title | Gestão do Orçamento Estrutural @Styles.Render("~/Content/css") @Scripts.Render("~/bundles/modernizr") When running the app in my development machine, i.e. localhost server, everything works pretty fine. So, I published the app to the server (running IIS 7.5). I checked that all the files were copied to the server properly. But when the app runs in the server the instruction bellow returns the HTTP Error 500! @Styles.Render("~/Content/css") From IE Developer Tools - Network I got the following infos: On Request headers section: Key                           Value Request                    GET /Content/css?v=l-tUJB_U4s5AmePYTduyfcgHbsPGttSRxnXdOtWONUU1 HTTP/1.1 On Response headers: Key                           Value Response                  HTTP/1.1 500 Internal Server Error Key                           Value Content-Length        4450 I've tried changing the bootstrap.flatly.min.csss to the original bootstrap.css. No success! I have similar apps, running in the very same server, that were built with the very same structure and use the very same style files. The BundleConfig.cs file have the same content, the section in _Layout.cshtml are the same, except for the ViewBag.Title. And all of them run properly. I noticed that in the similar apps, the value of Content-Length of that similar request (the bundled css) is [...]



Skip browser default print preview and print content directly to printer in jquery/javascript

2017-09-19T03:54:13.877-07:00

i am working in a billing system where when a user clicks ok, a receipt will be printed directly without any preview popping. the plan is i will manually configure the system to connect to a specific printer so whenever the ok button is clicked, only that printer will be used to prevent the risk of printing to other printers. so i have searched a lot in the net a javascript code that prevents print preview by placing it to an iframe. It is working fine to all the brosers however, a print set-up pops-up and i want it to be gone. i really want this to be removed because it is time consuming to always go to the print preview. is there a possible javascript code for it? or is it really possible? thanks.




how to refresh div without reloading whole page

2017-09-23T05:23:31.62-07:00

hi every one

I am working on mvc 4 , i have two div ,div1 and div2

div1 have drop downlist ,input box ,textbox etc ect

div2 have drop downlist ,input box Only

when i select item from dropdownlist in div2 i want to refresh only div2 and remain data as it is in div ,can any help me how to do this .




When @media screen max-width: 991px i want the menu fixed on top @media screen and (max-width: 991px) { .site-info { position:fixed; top:0; z-index:1000; } }

2017-08-22T12:06:10.297-07:00

Hi, in my website i have my menu which is already fixed when i scroll down but when i resize the screen the mobile menu does not stick on top...

i cannot achive this... i added this code on my style sheet but it does not work :

@media screen and (max-width: 991px) {
    .site-info {
        position:fixed;
        top:0;
        z-index:1000;
    }
}

How to make my mobile menu stick on top?

this is the website where you can check : 

http://www.magental.com/Annonce/Index




Regarding Angular JS

2017-09-22T18:22:51.487-07:00

Hi,

Apologies if i am posting in a wrong thread.

I am trying to learn Angular JS using sample application. Any samples that could help me learn Angular in depth.

Someone who can point to samples that can be downloaded.

Thanks a lot in Advance,

Ashvin




Angular JS Examples

2017-09-23T03:36:59.2-07:00

Hi,

Apologies if i am posting in a wrong thread.

I am trying to learn Angular JS using sample application. Any samples that could help me learn Angular in depth.

Someone who can point to samples that can be downloaded.

Thanks a lot in Advance,

Ashvin




Where to physically put general classes (containing general methods and data structures) in an MVC application?

2017-09-22T20:43:17.957-07:00

Where should I put general classes (that would contain general functions and methods) in an MVC class.   These classes and methods are not really part of a controller, nor do they have a view or model associated with them.  They are primarily classes with utility methods in them (ie. financial functions, or mathematical functions that my MVC app needs).

What's the recommended place for putting these, or should I just create a folder within the file structure and place them there?   They are all public classes and methods.




Http [Attribute], return value from Stored Procedure

2017-09-22T02:56:30.22-07:00

Hi All,

I need guidance for getting a return value from Stored Procedure.

This is the current Controller

        [HttpPost]
        public IActionResult Index (prj_Insert Project) {
            var Project = new SqlParameter("@Project", Project.Project);
            var State = new SqlParameter("@State", Project.State);
            var _Insert = _project.Database.ExecuteSqlCommand("[dbo].[Insert_Top1] @Project, @State"

                                                               , Project
                                                               , State);
            return View ();
        }

This is for Store Procedure and @ID_Project is for a return value. 

ALTER PROCEDURE [dbo].[Project_Code_Insert]
	-- Add the parameters for the stored procedure here

        @Project	NVARCHAR(5)
	, @State	NVARCHAR(3)
	, @ID_Project	INT             OUTPUT

AS
BEGIN
	INSERT INTO [dbo].[Tbl_Top1] ([Project], [State]) VALUES (@Project, @State)

	SELECT @ID_Project = @@IDENTITY

I know that controller above need modification to retrieve value from stored procedure but how to prepare a return value in the Controller ?

Please, advice me

Thanks in Adv, #D

 




message should be displayed when data is not available for chat

2017-09-21T15:36:41.87-07:00

I am populating 4 chart on ddlMonth_SelectedIndexChanged(object sender, EventArgs e) event.

I want that when data is not available for chart then chart should show a message that data is not available in spite of showing blank chart. how to do it.

 protected void ddlMonth_SelectedIndexChanged(object sender, EventArgs e)
    {
        G_Function.FillRepbyMonth1(ref Repeater1, ddlMonth.SelectedValue, ddlYear.SelectedValue, ref lblmsg, proname);
        G_Function.FillRepbyMonthSum(ref Repeater3, ddlMonth.SelectedValue, ddlYear.SelectedValue, ref lblmsg, proname1);
        FCLiteral.Text = CreateChart();
        FCLitera2.Text = CreateChart1();
        FCLitera3.Text = CreateChart2();
        FCLitera4.Text = CreateChart3();
    }

 public string CreateChart()
    {
        //In this example, we show how to connect FusionCharts to a database.
        //For the sake of ease, we've used an Access database which is present in
        //../App_Data/FactoryDB.mdb. It just contains two tables, which are linked to each
        //other. 
        //Database Objects - Initialization
        DbConn oRs; string strQuery;
        //strXML will be used to store the entire XML document generated
        string strXML;
        Util util = new Util();
        //Generate the graph element
        strXML = "";
        //SQL Query        
        strQuery = "select sum(cell_03) as scell_03, sum(cell_04) as scell_04, sum(cell_05) as scell_05 from praptra76 where month(r_date)='" + ddlMonth.SelectedValue + "' and year(r_date)='" + ddlYear.SelectedValue + "'";
        // Open Data Reader
        oRs = new DbConn(strQuery);
        //Iterate through each factory
        while (oRs.ReadData.Read())
        {
            strXML += "";
            strXML += "";
            strXML += "";

        }
        // Close Data Reader
        oRs.ReadData.Close();
        //Finally, close  element
        strXML += "";
        //Create the chart - Pie 3D Chart with data from strXML
        return FusionCharts.RenderChart("FusionCharts/FCF_Funnel.swf", "", strXML, "FactorySum", "680", "300", false, false);
    }

 




Bootstrap images

2017-09-22T21:37:13.573-07:00

I have 4 images to display equally in html using bootstrap. Each of the 4 images are different sizes but the 4th one appears larger than the first 3.  Below is my page code and feedback is appreciated.

    




Need help on Rest calls

2017-09-22T19:49:03.663-07:00

Hello All,

I am having issues on how I can have multiple gets in my restful class, and how to call them.

I am guessing this would be a routing issue, but I don't know how to setup my routing or how I would call different methods.

Right now I have 2 methods that both take a string param and return that same param.

 public string GetPriceForCustomer(string id)
		{
			try
			{
               
				ConnectionStringSettings connectionString = ConfigurationManager.ConnectionStrings["ERP"];
               
                using (SqlConnection cn = new SqlConnection(connectionString.ConnectionString))
				{
                   
                    using (SqlCommand command = new SqlCommand("salesforce_getProductPrice", cn))
					{
                     
                        command.CommandType = CommandType.StoredProcedure;                       
                        cn.Open();                       
                        string tmp = command.ExecuteScalar().ToString();
                        return "price is " + tmp.ToString() + " ID is " + id;
                    }
				}
			}
			catch (Exception e)
			{
				Trace.WriteLine(e.Message);
                return "Error in rest " + e.Message;
				
			}
		}
 public string GetPriceForCustomerA(string boo)
		{
			try
			{
               
				ConnectionStringSettings connectionString = ConfigurationManager.ConnectionStrings["ERP"];
               
                using (SqlConnection cn = new SqlConnection(connectionString.ConnectionString))
				{
                   
                    using (SqlCommand command = new SqlCommand("salesforce_getProductPrice", cn))
					{
                     
                        command.CommandType = CommandType.StoredProcedure;                       
                        cn.Open();                       
                        string tmp = command.ExecuteScalar().ToString();
                        return "price is " + tmp.ToString() + " ID is " + boo;
                    }
				}
			}
			catch (Exception e)
			{
				Trace.WriteLine(e.Message);
                return "Error in rest " + e.Message;
				
			}
		}

How do I set this up to be able to call either one of these methods?

Thanks for any help or advice,

KSS




Multiple databases for authenticating web api2

2017-09-22T23:35:11.83-07:00

Hello,

I have built a web api and using token based authentication for authenticating user. Till now the users where in the one database and we are going to use different second database for authentication. 

Now Issue is I don't know how to authenticate using two different databases. Basically token has to be created from different databases.

I tried changing dbcontext on runtime which I wasn't able to do for token generation.

Any help will be really helpful.

Thanks,

Vivek