VS 2008 Pagemethod When Creating New Record?

Oct 21, 2010

I have a pagemethod that saves data to my database. Initially I worked on editing an existing record. So I'd load a page by adding the FileNumber to the url:

Code:
[URL]

for example. Then on the click of my save button I send all the textbox ojects etc to a javascript function which then gets the values to save, and passes them to my pagemethod. I did this so I won't have to have refresh the page each time a user updates the file. ajxaified it in other word. Now whan creating a new record, I pass -1 as the fileNumber in my querystring. I do this so in my code, I will know it is a new record and I will write the required logic. However once the new file is created, I get the its primary key value by using SCOPE_IDENTITY(). then unless I refresh the page from my javascript function the url will remain

Code:
[URL]

View 16 Replies


Similar Messages:

C# - Creating Instances Of A Class Inside A Static PageMethod Thread Safe?

Dec 14, 2010

I am using jQuery to call PageMethods. For certain operations, the current user credentials must be validated and for other operations, I need to call other static methods. Here is some sample code:

Sample #1

[WebMethod]
public static void PostComment(string comment)
{
UserAuth auth = new UserAuth();
if (auth.isAuthenticated)
{
//Post comment here...
}
}

Sample #2

[WebMethod]
public static string GetComment(int commentId)
{
commentDto comment = //get comment data from the database...
string friendlyDate = ConvertFriendlyDate(comment.commentDate);
return friendlyDate + " " + comment.text;
}
public static string ConvertFriendlyDate(DateTime commentDate)
{
string friendlyDate = //call static utility method to convert date to friendly format
return friendlyDate;
}

Will I be safe using these kinds of operations? Am I better to drop page methods and just call a separate ASPX page for my AJAX requests?

View 4 Replies

VS 2008 - PageMethod Not Working "The Server Method Testing Failed"

Oct 28, 2010

I have a master page/content page going on in this situation. The page has two page methods that work, and they feed info to a pair of autocomplete extenders. The script manager on the Master Page has 'EnablePageMethods' set to true. The content page has a ScriptManagerProxy. The strange thing is that I have used this pattern on four other pages within the project.

<System.Web.Services.WebMethod()> _
Public Shared Function testing(ByVal uid As String, ByVal issn As String, ByVal journalName As String) As String
Return "true"
End Function

Here is the javaScript code:

function AddJournal(uid, issn, journalName) {
alert("uid: " + uid + " issn: " + issn + " name: " + journalName);
PageMethods.testing(uid, issn, journalName,
function(res) {
if (res !== "true") {
alert(res);
} else {
alert("The journal " + name + ", issn as " + issn + " was successfully entered.");
}
return;
},
function(res) {
alert("The journal database could not be accessed
" + res.get_message() + "
Status Code: " + res.get_statusCode() + "
Exception Type: " + res.get_exceptionType() + "
Please try again.");
});
}

The fail function is executed, and the status code is 0 (zero), and the exception type is an empty string. I can change the function with no parameters, and I get same error. I can the leave the parameters at three on the VB side, and change the parameters to two on the client side; then I do not get the error message, but none the other alerts are executed.

View 3 Replies

Forms Data Controls :: Using A CheckBox In A FormView Template For Creating A New Record?

Nov 11, 2010

I'm putting together a page that allows the user to enter a new record in an SQL table. A bunch of the fields in the table are bit datatypes. I want to use CheckBoxes to correspond to the bit datatype columns in the SQL table.

How do I bind the checkboxes to the SQL table columns?

Here's what I have, not sure if this is right:

[Code]....

View 1 Replies

Crystal Reports :: Only 1st Record Getting Displayed Not Others In CR 2008

Mar 24, 2010

I have 2 parameters 1. InvoiceNum: this is array of InvoiceNumbers and 2. CompanyNickName. A single string value Now when I am passing these parameters to report only 1st record is getting displayed and not others. Ideally no. of records should be equal to no. of InvoiceNums e.g. if there are 3 invoice no. it shoudl display all 3 invoices. here is relevant code

private
void SetCurrentValuesforParameterField(
ArrayList InvoiceNumList)
ParameterFields param =
new
ParameterFields();
ParameterValues vals =
new
ParameterValues();
ParameterField parameterfield =
new
ParameterField();
foreach (object submittedValue
in InvoiceNumList)
ParameterDiscreteValue InvoiceDiscreteVal =
new
ParameterDiscreteValue();
ParameterValueKind.StringParameter; //ParameterField parameterfield1 = param[1];
parameterfield =new
ParameterField();
ParameterValueKind.StringParameter;
ParameterDiscreteValue InvoiceDiscreteVal1 =
new
ParameterDiscreteValue();
new
ParameterValues(); //
CrystalReportViewer1.ParameterFieldInfo = param;
}
vals.Add(InvoiceDiscreteVal1);
parameterfield.CurrentValues = vals;
param.Add(parameterfield);
InvoiceDiscreteVal1.Value = CompanyNickName;
vals =
parameterfield.Name = Parameter_Field_Name1;// 2nd Parameter CompanyNickName
parameterfield.ParameterValueType = parameterfield.CurrentValues = vals;
param.Add(parameterfield);
}// End of Loop
InvoiceDiscreteVal.Value = submittedValue.ToString();
vals.Add(InvoiceDiscreteVal);
parameterfield.Name = Parameter_Field_Name; //1st Paramt name InvoiceNum
parameterfield.ParameterValueType =
ParameterDiscreteValue InvoiceDiscreteVal1
new
ParameterDiscreteValue();
new
ParameterValues();
//
CrystalReportViewer1.ParameterFieldInfo = param;
}
vals.Add(InvoiceDiscreteVal1);
parameterfield.CurrentValues = vals;
param.Add(parameterfield);
InvoiceDiscreteVal1.Value = CompanyNickName;
vals =
new
ParameterValues();
//
CrystalReportViewer1.ParameterFieldInfo = param;
}
vals.Add(InvoiceDiscreteVal1);
parameterfield.CurrentValues = vals;
param.Add(parameterfield);

View 1 Replies

VS 2008 Creating Dynamic Menus With C1Menu?

Mar 18, 2010

Does anyone out there use ComponentOne's C1Menu and create a menu with subitems at runtime? I have went through their forums and help and anything at runtime is done with C1WebMenu which was replaced with this version.I need to create the whole menu with subitems. Can you show code for this if you have?

View 1 Replies

VS 2008 Creating User Account Policy ?

Feb 20, 2011

I would like develop an application written in ASP.NET which include an option to configure user accounts in such a way that each user account can be freely assigned to a different module to which it will has access.

So, for example, I would have one table in a database that maps user to modules.

In ASP.NET there is the whole mechanism of roles, but his assumptions are slightly different -> Here you need to centrally configure finished profiles. This can be circumvented in such a way that each application module is a separate role. And for one user can be assigned multiple roles.

But whether such a method is elegant? Should I do it differently?

View 1 Replies

VS 2008 - Creating A Form That Upload A File

Apr 10, 2010

I'm not sure where this should go (I don't know whether it's a database problem, or a code problem), but I think it's a code problem, so I'm posting here.

I'm working with a database that is storing images (actually, it's a modified version of the AdventureWorks database from Microsoft), and I'm creating a form that will let you upload a file. I've got a business object based on the table that I'm using (Production.ProductPhoto) and I'm using two stored procedures to either get (Production.ProductPhoto_Get) or add (Production.ProductPhoto_Add) an entry from/to the table. The image is being stored as a varbinary field in the database, and a Byte() in my business object.

The problem I'm having is that when I'm adding a new entry and uploading a file, the length of the file uploaded is correct (so I assume everything is going smoothly), and it gets passed along to my ProductPhotoProvider DAL class where I create a DbCommand and add the parameters for my stored procedure. The information is all added to the database successfully, and I'm returned the identity of the new entry as expected -- however, when I try to read this image back, it seems that the length is 1. I've put in break points and stepped through everything, and I don't know what's going on.

I think that I know my ProductPhotoProvider class is at least reading things correctly -- I can display other images from the database (that came with the database, that is) just fine. Mine just all come back with a length of 1.

I'm just hoping someone knows what the hell I'm talking about; I have a lot of programming experience, but this is my first major venture into ASP.NET. I have no idea which parts of my code are relevant, so I'll just post my Add and Lookup functions for now?!

[Code]....

My ProductPhotoProvider class is based off of an abstract class called AbstractDALProvider (which I can also provide if needed). I can provide the rest of my project, if needed, too.

Oh, and for good measure: I was told that when you used to store images in Microsoft Access, there was some sort of problem when retrieving the data and you'd have to strip the first 72 bytes of data from it, or something. I can only assume that this is not a problem here, because I have no problem displaying other photos that were not created by me.

View 6 Replies

VS 2008 Creating Role Based Authorization?

Feb 9, 2011

I have seen articles on Role Based Authorization in MS-Sql server-Asp.net but i did not find any article in MySql-ASP.net/vb.net, i am acheived this concept using session user name i am enabling certain parts of website to group A and certain parts of site to Group B but when i have more groups i cannot use this method.

Myrequirement is:

In Web applications, typically there exist certain parts of the site that only certain folks, or groups of persons can access. For example, imagine Web site used to administer the content on a company's public Internet Web site, where the public Web site lists products sold by the company. From the administrative site, all company employees might be able to make minor changes to the products' descriptions, quantity, and other such non-essential information. However, perhaps only a subset of trusted employees might be able to change the products' prices. And even a smaller subset of employees would be able to add new products or delete existing products from the database I would be delighted if any one provide the solution

View 9 Replies

MVC :: Creating A Few Web Sites With SQL Server 2008 And Hosting Them In IIS7?

Jan 25, 2010

I have been creating a few MVC web sites with SQL Server 2008 and hosting them in IIS7.

However, at the moment I need to host one of the web sites with IIS6.

Will I have any problem?

The client requested to use their current hosting service which is IIS6 so I have no idea if some problem will come up.

View 1 Replies

VS 2008 Registration Form - Creating Expiring Cache

Sep 27, 2011

So I'm attempting to limit user's access to my database through the web. I have a registration form that asks the user for a name and password, then verifies this against a DB. In order to prevent DB overload, I will limit the user's attempts to 10 in 10 minutes. This is how I am trying to solve this, but cannot verify that i'm using the right approach.

Code:
Dim timeout As Integer = ConfigurationManager.AppSettings("timeout")
Dim userIPkey As String = Me.Context.Request.ServerVariables("REMOTE_ADDR")
Dim i As Integer
If HttpContext.Current.Cache(userIPkey) = Nothing Then
i = 1

[Code] .....

For some reason I can hit the service with a for loop and get to the DB every time. If I try doing this through the browser while debugging the webpage, I get the right error message after 10 attempts, while on the server, or through a reference to localhost I will not get the error message.

View 3 Replies

VS 2008 - Creating Gridview User Control With Sorting And Filtering?

Sep 20, 2010

I find myself always repeating code when it comes to gridviews. I want to build a usercontrol so I can just set a datasource andcolumn types etc and I can use the same control over and over in different projects.

View 4 Replies

Web Forms :: Visual Studio 2008 Professional Not Giving Option For Creating New Website?

Mar 29, 2010

I am currently using VS 2008 Pro for an ASP.Net class. I got VS from school as part of MSDNAA program. It is version 9.0.21022.8 with .NET framework 3.5 SP1.

My problem is that when I start it up, it does not give me the option to Create or Open a Website. It only gives me the option to Create or Open a Project. So, when I start my homework or in-class assignments, I have to press Shift+Alt+N to Create a Website.

Where the problem comes in is after I start working on the website, I hit Save and it changes it to a Solution. This seemed to have caused a problem with BIND commands being lost in my last homework assignment. Is there something wrong with my install or a setting I can change? I'd rather not reinstall it unless I have to since it is such a pain to uninstall it in the first place.

View 2 Replies

Calling Vb Pagemethod From Ajax?

Feb 18, 2011

I have a simple aspx file with 2 text boxes and an ajax autocomplete extender attached to textbox2

[code]....

This not working.. How can i make it work?

View 1 Replies

Trying To Call A PageMethod Using JQuery?

Feb 10, 2011

I am trying to call a PageMethod using jQuery like this:

[WebMethod]
public stataic string WebMethod(PostData data)
{
//DO WORK
return "a";
}

PostData class is as follows:

[Code]....

View 2 Replies

AJAX :: PageMethod Does Not Respond?

Mar 18, 2010

I have a long running process that i kick off with a pagemethod that normally takes about an hour to complete, when it is finished it returns the result of the method.I then poll with another pagemethod to update the status of the first process.the process is taking 4.5 hours this week which is acceptable and understandable, but the feedback sometimes gives up after a couple of hours and sometimes the main method never returns any feedback to the client.

Regardless of the lack of status updates and final feedback the server still completes the long task.As far as i'm aware we have made no changes to any timeout values.is there a timeout setting that we are hitting that is above 1 hour for ajax methods?

View 2 Replies

Jquery - Set Session In PageMethod?

Apr 5, 2011

I need to set a couple of Session vars by calling a PageMethod using jQuery.

The client side js looks like this:

function setSession(Amount, Item_nr) {
//alert(Amount + " " + Item_nr);
var args = {
amount: Amount, item_nr: Item_nr
}
//alert(JSON.stringify(passingArguments));
$.ajax({
type: "POST",
url: "buycredit.aspx/SetSession",
data: JSON.stringify(args),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function () {
alert('Success.');
},
error: function () {
alert("Fail");
}
});
}

and the server side like this:

[System.Web.Services.WebMethod(EnableSession = true)]
public static void SetSession(int amount, int item_nr)
{
HttpContext.Current.Session["amount"] = amount;
HttpContext.Current.Session["item_nr"] = item_nr;
}

only, it seems that the Session vars are not set. When I try to Response.Write out the Session vars, I get nothing. I get no errors, and I can alert out the values passed from the onclick event, to the js function, so they are there.

View 2 Replies

How To Get Ajax.Net PageMethod To Return JSON

Jan 12, 2010

I am using an AJAX.Net to call an ASP.Net PageMethod, which returns JSON serialized JSON data

{"d":"[{"Fromaddress":"testfrom1@test.com","Toaddress":"testto1@test.com"},{"Fromaddress":"testfrom2@test.com","Toaddress":"testto2@test.com"}]"}

The Response Header states the content type as

"Content-Type application/json; charset=utf-8"

However, the data is just available as a string, and does not seem to be available as JSON data from javascript. What do I need to do to work with the returned data as JSON from javascript?

View 1 Replies

AJAX :: UseHttpGet Causes PageMethod To Fail?

May 30, 2010

I have a PageMethod that works perfectly well when it either (a) running in the VS dev server, or (b) deployed but marked with UseHttpGet=false.

What doesn't work, and is driving me mad, is having UseHttpGet=true and then deploying it to a test server (Vista & IIS7). It fails to call through the proxy with error code 404 coming back. But it works find if I set UseHttpGet=false.

I have gone through all of the basic stuff I can think to check, and as noted it works perfectly well on the dev box. So there must be something particular about full-blown IIS7 and its config that I am missing..

anything to check in the IIS manager that would cause this to fail? I've tried with forms authentication enabled and disabled, as a few posts mentioned issues with that.

View 1 Replies

AJAX :: Pagemethod Authentication Failed?

Mar 3, 2011

I have a page that requires user login via Forms Authentication. Is it possible to use Page Methods in this page? My current attempt is resulting in the following error:Message: Sys.Net.WebServiceFailedException: The server method 'GetPlanContent' failed with the following error: System.InvalidOperationException-- Authentication failed.

View 2 Replies

Web Forms :: PageMethod/WebMethod Not Being Executed?

May 13, 2010

PageMethod which supposed to be called/executed when "onChange' of dropdownlist is triggered is Not being executed. I have 3 dropdownlist being created at runtime/dynamically inside a compositecontrol class and loaded (.dll) in a page at runtime. I have added a scriptmanager in the master page and set EnablePageMethods to true, tried placing the webmethod function outside of the compositecontrol and in the page, still webmethod is not being called... Anyone has idea or solution to this problem of mine? Or another approach to retain the selected value of the dropdownlist inside this compositecontrol (.dll) that is being loaded in a page at runtime?

[Code]....

View 2 Replies

AJAX :: Use A AutoCompleteExtender On A MasterPage With PageMethod?

Jun 28, 2010

I put my ScriptManger on the top level Masterpage with EnablePageMethods set to "true".2. I put a AutoCompleteExtender (AjaxToolkit) on a second level Masterpage which derives from the top level MasterPage. The AutoCompleteExtender is used for search with a TextBox. The PageMethod is defined in the Code Behind of this second level Masterpage.3. I have several Contentpages that derive from the second level Masterpage.Problem: The AutoCompleteExtender does not work and that's probably because the PageMethod is defined in the second level MasterPage in the CodeBehind and not in the Contentpage. Ok, so I'm pretty sure what causes the error,- I do not want to use a WebService, because I don't want the search to become public. And as far as I know you can't define a WebService that is only visible to the Website itself - it's always public.- It would be stupid to put the search on every Contentpage just for the PageMethods sake.

View 1 Replies

AJAX :: PageMethod Not Working With IIS6

Jun 16, 2015

My website is running fine on my local system but when i upload it on IIS6 of my local computer [Ajax.AjaxMethod] is not working. How i will solve it.

View 1 Replies

Web Forms :: Render User Control In PageMethod?

Nov 9, 2010

I want to render a user control in pagemethod and return the html back to client. But its getting annoying, I tried like many ways but nothing found working. The problem is that, the usercontrol require both HtmlHead and ScriptManager.

I tried this but it doesn't work(raise error : ScriptManger require in page) because ScriptManager must be inside HtmlForm but Page.Form always null.

[Code]....

View 8 Replies

How To Call A Pagemethod In A User Control Using Jquery

Mar 21, 2011

I have a user control having a pagemethod. I want to call this pagemethod from my page using jquery's ajax() method?

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved