|
jeevanjoshi wrote: I am only worried about load on browser and DB Typically, your code won't change much as long as you write good code to begin with. Handling an increase in load is done by configuring servers, not changing code.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
Hi all,
I am very new to ASP.net MVC.
I am creating a simple web application and want capture and save the userID to a newly created record by the user.
The reason is, I want users only can edit the records they created if not their record then only can view (except for the admin ofcourse).
modified 16-Oct-14 8:41am.
|
|
|
|
|
It is not clear what is the question.
I beleive getting the current username inside a controller can be done like this:
Username = User.Identity.Name
|
|
|
|
|
Thanks so much for the respond.
Part 1. Get the user ID.
Part 2. Write the user ID to the Database (server side)
So, Username = User.Identity.Name is to get the user ID.
Now how do I write the user ID to the table (the database).
|
|
|
|
|
I'm really not that familiar with MVC development, but I believe the SQL necessary to store the UserID would be in a "Model".
|
|
|
|
|
Does anyone have a sample code for me to write UserId to the table (database server side)?
Help.....I stuck
|
|
|
|
|
I want validation code in separate js file and include it on content page in asp.net
How can I use controls on content page with js file ?
Please provide solution with custom example.
|
|
|
|
|
Your question contradicts the title
Your should probably use jquery first
So you right click on solution exploer, add file JScript, and name it validate.js
Then create a function
function validate_text() {
var vFlag = true;
var txtFocus = 'rgb(255,255,255)';
var txtError = 'rgb(255,0,0)';
var message_value = $('[id*="_txt_CRM_VCM_MessageReply_Field"]').val();
if (message_value.length < 2) {
$('[id*="_txt_CRM_VCM_MessageReply_Field"]').css('border', 'solid 1px ' + txtError);
vFlag = false;
}
else {
$('[id*="_txt_CRM_VCM_MessageReply_Field"]').css('border', 'none');
}
return vFlag;
}
On your Button, program the OnClientClick property
<asp:TextBox ID="_txt_CRM_VCM_MessageReply_Field" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return validate_text(); " />
Now drop in your jquery, this will dowmload jquery to the page for use in your validate.js
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
or download jquery and create a jquery.js file where you placed your validate.js file
Make a reference to validate.js
Use the solution explorer and drag the file to within the head tags, and the script tag will automatically be formed.
|
|
|
|
|
I have a page like this:
<%@ Page Title="test" Language="C#" MasterPageFile="~/Template.master" CodeFile="Define.aspx.cs" Inherits="JobRecords_Default" EnableEventValidation="false"%>
<script type="text/javascript">
function changeFunc() {
var selectBox = document.getElementById("selectBox");
var selectedValue = selectBox.options[selectBox.selectedIndex].value;
window.location.href = '?s=' + selectedValue;
}
</script>
<form role="form">
<label>Ward:</label>
<select id="selectBox" class="form-control" onchange="changeFunc();" runat="server">
<option value="1">Ward 1</option>
<option value="2">Ward 2</option>
<option value="3">Ward 3</option>
</select>
<asp:Button ID="btnRegister" CssClass="btn btn-lg btn-block btn-success" runat="server" Text="Register" OnClick="btnRegister_Click" ></asp:Button>
</form>
I want to use
changeFunc() in my selectBox onchange event
If in the first line I set EnableEventValidation to false changeFunc() wont fire and if I set EnableEventValidation to true after clicking the btnRegister I will see below error:
Quote: Invalid postback or callback argument. Event validation is enabled using <pages enableeventvalidation="true"> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
is there any one who can help???
|
|
|
|
|
True!
The problem is that you do not initiate post-back but change location...That makes ASP.NET engine think that you are not you!
The best you can do is to use DropDownList[^] control of ASP.NET...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Thank you so much
I think it is the wisest way
|
|
|
|
|
<pre lang="sql">Scenario is I have one parent and on child page. Child page contain list of say countries. I was using showModalDialog function in java script which is easily returned the value I had selected in my child page. Recently this functionality is not working in chrome as in new update they have deprecated showModalDialog function. Please suggest me some alternative to achieve this.
I tried same using different methods but issue I am facing is there are multiple values returning from child which I have to split and assign to my hidden values in parent:</pre>
|
|
|
|
|
You have already posted this in QA[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
public DataSet ReadPreviousProperty(Guid appIDValue)
{
DataSet ds1 = new DataSet();
try
{
con = new SqlConnection(connectionString);
SqlDataAdapter da1 = new SqlDataAdapter(); ;
SqlCommand cmd1 = new SqlCommand("[sp_ReadPreviousProperty]", con);
cmd1.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@ApplicationID", SqlDbType.UniqueIdentifier).Value = appIDValue;
if (con.State == ConnectionState.Closed)
con.Open();
da1.SelectCommand = cmd1;
da1.SelectCommand.Connection = con;
da1.Fill(ds1, "tblPropertyMaster");
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
}
finally
{
if (con.State == ConnectionState.Open)
con.Close();
}
return ds1;
}
cmd.Parameters.Add("@ApplicationID", SqlDbType.UniqueIdentifier).Value = appIDValue;
this line raises error ,object reference is not set to an instance
please check my code and answer
|
|
|
|
|
Have a look into AddWithValue[^]. your syntax is wrong, the .VALUE is invalid in the constructor.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Huma Ansari wrote:
SqlCommand cmd1 = ...
cmd.Parameters.Add(...
Those are two different variables. You're getting a NullReferenceException because you haven't initialized the cmd variable.
Change your code to either:
cmd1.Parameters.Add("@ApplicationID", SqlDbType.UniqueIdentifier).Value = appIDValue;
or:
cmd1.Parameters.AddWithValue("@ApplicationID", appIDValue);
Other comments:
The SqlDataAdapter class takes care of opening and closing your connection for you, so there's no need to explicitly open the connection before calling the Fill method.
The SqlCommand constructor has already assigned the connection; there's no need to set da1.SelectCommand.Connection to the same connection instance.
You should also look at wrapping your connection and command objects in using blocks, and avoid storing them in fields.
using (SqlConnection con = new SqlConnection(connectionString))
using (SqlCommand cmd = new SqlCommand("[sp_ReadPreviousProperty]", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@ApplicationID", appIDValue);
SqlDataAdapter da1 = new SqlDataAdapter();
da1.SelectCommand = cmd;
DataSet ds1 = new DataSet();
da1.Fill(ds1, "tblPropertyMaster");
return ds1;
}
Finally, using sp_ as the prefix for a stored procedure is not a good idea:
http://sqlperformance.com/2012/10/t-sql-queries/sp_prefix[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
<script type="text/javascript" language="JavaScript">
function PrintPage(pageheader) {
var wPageHeader = pageheader
var curDate;
var advNo='<%=ddlAdvertise.selecteditem.text%>';
var post='<%=ddlPost.selecteditem.text%>';
var wOption = "width=875,height=525,menubar=yes,scrollbars=yes,location=no,left=20,top=20";
var wWinHTML = document.getElementById('printArea1').innerHTML;
var wWinPrint = window.open("", "", wOption);
wWinPrint.document.open();
wWinPrint.document.write("<html><head><link href='../Styles/Print.css' rel='stylesheet'><title>e-Despatch</title></head><body>");
wWinPrint.document.write("<div id='header'><div style='float:center;margin-top:10px;'></div> <div style='float:center; margin-top:0px;' width='220'>       <b> Advertisement No:"+advNo+"</b>       <b> Post Code:"+post+"</b></div><div style='float:center;margin-top:0px;'><b>"+wPageHeader+"</b></div><div style='float:right' align='right'><div align='right' id='printDate'></div></div><div style='clear:both'></div></div>")
//wWinPrint.document.write("<div align='center' id='printHeader'>" + wPageHeader + "</div>");
//wWinPrint.document.write("<div align='right' id='printDate'>"+curDate+"</div>");
wWinPrint.document.write(wWinHTML);
wWinPrint.document.write("</body></html>");
wWinPrint.document.close();
wWinPrint.focus();
}
</script>
|
|
|
|
|
But only the data in current grid was captured using the following method
mya=jQuery(”#list2″).getDataIDs(); // Get All IDs"
If I like to export all data (e.g. totally 18 records, 10 displayed in current grid and 8 in second grid page), is there a way to capture all 18 records without invoking the backend?
i am not finding any solution only first page data is capturing in excel ...
I am using
var jqgridRowIDs = $(tableCtrl).getDataIDs(); // Fetch the RowIDs for this grid
var allJQGridData = $(tableCtrl).jqGrid('getRowData');
var headerData = $(tableCtrl).getRowData(jqgridRowIDs[0]);
Plz help me out.....
|
|
|
|
|
Can you not dump data source of the jqgrid and save as csv?[^]
dev
|
|
|
|
|
i was just reading a article on Self hosting SignalR Application in Win Service from this url http://damienbod.wordpress.com/2014/06/03/signalr-self-hosting-template-for-a-windows-service/
code was not very clear to me.so here i am pointing out those line of code point wise. apologized for bit big question.
namespace SignalREngineServiceWindowsService
{
static class Program
{
static void Main(string[] args)
{
ServiceBase.Run(new SignalREngineServiceWindowsService());
if (args != null)
{
try
{
Startup.StartServer();
Console.ReadKey();
}
finally
{
Startup.StopServer();
}
}
}
}
}
[assembly: OwinStartup(typeof(Startup))]
namespace SignalREngine
{
public class Startup
{
static CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
public static void StartServer()
{
var cancellationTokenSource = new CancellationTokenSource();
Task.Factory.StartNew(RunSignalRServer, TaskCreationOptions.LongRunning
, cancellationTokenSource.Token);
}
private static void RunSignalRServer(object task)
{
string url = "http://localhost:8089";
WebApp.Start(url);
}
public static void StopServer()
{
_cancellationTokenSource.Cancel();
}
public void Configuration(IAppBuilder app)
{
app.Map("/signalr", map =>
{
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration
{
};
hubConfiguration.EnableDetailedErrors = true;
map.RunSignalR(hubConfiguration);
});
}
}
}
1) just see this line...what is the meaning
ServiceBase.Run(new SignalREngineServiceWindowsService());
how we can instantiate namespace because this is the namespace name SignalREngineServiceWindowsService i think we should specify the class name...what u say!
2)
public static void StartServer()
{
var cancellationTokenSource = new CancellationTokenSource();
Task.Factory.StartNew(RunSignalRServer, TaskCreationOptions.LongRunning
, cancellationTokenSource.Token);
}
here we are calling a method with TPL but what is the meaning of this option or param TaskCreationOptions.LongRunning and cancellationTokenSource.Token ?
3)
private static void RunSignalRServer(object task)
{
string url = "http://localhost:8089";
WebApp.Start(url);
}
see this url string url = "http://localhost:8089"; here can't we specify machine IP where self host apps will run? is it mandatory to write like localhost ?
4)
public static void StopServer()
{
_cancellationTokenSource.Cancel();
}
what will happen when this line will be invoked _cancellationTokenSource.Cancel(); ?
how it can stop the signalr hub ?
5)
public void Configuration(IAppBuilder app)
{
app.Map("/signalr", map =>
{
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration
{
};
hubConfiguration.EnableDetailedErrors = true;
map.RunSignalR(hubConfiguration);
});
}
who will call Configuration() function because i found no routine in code from where Configuration() will be called ?
6) RunSignalR() ? is any built-in function ?
7) what is the difference between this line map.RunSignalR(hubConfiguration); and map.MapSignalR(); ?
8) i found another approach to point out the startup class....here it is
static void Main(string[] args)
{
string url = "http://localhost:6118";
using (WebApp.Start<Startup>(url))
{
Console.WriteLine("The Server URL is: {0}", url);
Console.ReadLine();
}
}
class Startup
{
public void Configuration(IAppBuilder MyApp)
{
MyApp.MapSignalR();
}
}
what is Startup class & what it does or what its role in self hosting ?
i just go through a article and after reading it lots of confusion occur. so i just need answer for my question. so it will be great if some one answer point wise.
here i am including few more url which also talk about signalr selfhost but their coding approach is bit different but understandable.
here is those url
http:
https:
http:
tbhattacharjee
|
|
|
|
|
I had developed a dot net website in c#.I want to embed a video in my website,which should be compatible in all browsers without using html5.I had tried but the video is playing or compatible on IE only.What should i do.please provide some suggestions or code.I will be grateful to you.
|
|
|
|
|
I am getting the following error
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
<wsa:Action>http://schemas.xmlsoap.org/ws/2004/08/addressing/fault</wsa:Action>
<wsa:MessageID>urn:uuid:13dee3e0-d36f-4b94-b769-d981fe391ed8</wsa:MessageID>
<wsa:RelatesTo>urn:uuid:a506294f-dea5-4ada-b1b2-a3677e00dcce</wsa:RelatesTo>
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
<wsse:Security>
<wsu:Timestamp wsu:Id="Timestamp-0b0b00f2-2c73-47cb-b951-0f2f8f555dd8">
<wsu:Created>2014-10-12T20:04:40Z</wsu:Created>
<wsu:Expires>2014-10-12T20:09:40Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</soap:Header>
<soap:Body>
<soap:Fault>
<faultcode xmlns:q0="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">q0:Security</faultcode>
<faultstring>Microsoft.Web.Services3.Security.SecurityFault: Header http://schemas.xmlsoap.org/ws/2004/08/addressing:Action for ultimate recipient is required but not present in the message.
at Microsoft.Web.Services3.Design.RequireSoapHeaderAssertion.RequireSoapHeaderFilter.ProcessMessage(SoapEnvelope envelope)
at Microsoft.Web.Services3.Pipeline.ProcessInputMessage(SoapEnvelope envelope)
at Microsoft.Web.Services3.WseProtocol.FilterRequest(SoapEnvelope requestEnvelope)
at Microsoft.Web.Services3.WseProtocol.RouteRequest(SoapServerMessage message)
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)</faultstring>
<faultactor>http://localhost:4190/AeslPSWebService.asmx</faultactor>
</soap:Fault>
</soap:Body>
</soap:Envelope>
and my request is as follows
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<_0:Security soap:actor="www.toromont.com" soap:mustUnderstand="true" xmlns:_0="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:_0_1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<_0_1:Timestamp _0_1:Id="Timestamp-135">
<_0_1:Created>2014-10-10T13:48:35.832Z</_0_1:Created>
<_0_1:Expires>2014-10-19T13:53:35.832Z</_0_1:Expires>
</_0_1:Timestamp>
<_0:UsernameToken _0_1:Id="UsernameToken-136">
<_0:Username>sa</_0:Username>
<_0:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Allied@CAT</_0:Password>
</_0:UsernameToken>
</_0:Security>
<par:UserCredentials xmlns:par="http://www.cat.com/MT/2008/11/15/PartStoreRequiredService"/></soapenv:Header>
<soapenv:Body>
<se:getCustomerInformation xmlns:se="http://www.cat.com/MT/2008/11/15/PartStoreRequiredService" xmlns:xsd="http://customerlookup.partstore.domain.webservice.midtier.websolutions.dcs.cat/xsd">
<se:custLookUpInput>
<xsd:custNo>99008</xsd:custNo>
<xsd:custType xsi:nil="true"/>
<xsd:dealerCode>X130</xsd:dealerCode>
</se:custLookUpInput>
</se:getCustomerInformation>
</soapenv:Body>
</soapenv:Envelope>
I have developed this web service for our vendor based on the wsdl they provided. Please help as i am unable to find any solution of it.
|
|
|
|
|
|
I currently find where the user clicked inside an image using e.X and e.Y in an onclick method, but I'd like to show the user what he's pointing at before he clicks and does a postback to the server. Rather like a mouseover. However, I haven't been able to pick up a mouseover event with a JScript function in my .net page.
I barely know JScript, but I have used functions to handle onkeypress events.
Any pointers, articles, links or well-deserved cynical remarks?
|
|
|
|