Get Return Value Of Javascript Function From Aspx.vb?
May 8, 2010How to get return value of java script function from aspx.vb..
View 1 RepliesHow to get return value of java script function from aspx.vb..
View 1 RepliesFor example, I have master page MyMasterPage.aspx and content page MyDefault.aspx. I have many UpdatePanels at MyMaterPage.aspx, and also I have many UpdatePanels at MyDefault.aspx.
[code]....
I want JavaScript functionClickMenu(this) at input button [id="ButtonMaster1" @ MyMasterPage.aspx] pass its value ["Menu-1"] into text box [id="TextBoxDefault1" @ MyDefault.aspx], and then performing update / doing post-back to server ONLY FOR UpdatePanelDefault1.
I am looking forward an example code for JavaScript functionClickMenu(this).
I call the javascript function in cs using button.attributes.add("onclick","function();");
how can i return a val to cs's string variable from js?
I want to send value from text on text keypress event in C# Code Behind Function. or get value from server side script function which called on textbox keypress event to C# Code Behind Function. How i do that
View 2 RepliesI have web page that will call the macromedia detection tool kit. But I cannot get the hasReqestedVersion value before the page is loaded. I tried to use RegisterClientScriptBlock or RegisterStartupScript inside of the Page_load function.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head runat="server">
<script type="text/javascript" src="AC_OETags.js" language="javascript"></script>
<script language="JavaScript" type="text/javascript">.......
So in default.aspx I have the code
<script type="text/javascript">
function validateForm()
{ [Code]....
When I call test() from javascript i want it to return false but cant seem to geta value from test.
I have some ajax fucntions on my default.aspx that I use for saving data to my db. I have the form on my web control. When I try calling the function from my button which resides on the web control. I get an error.
I need to call that function from my registerform.ascx. How do I do that from within the registerform code behind?
function ShowAvailability() {
$.ajax({
type: "POST",
url: "Default.aspx/CheckEmail",
data: '{usermail: "' + $("#<%=subs_email.ClientID%>")[0].value + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function(response) {
alert(response);
}
});
how can i call javascript function from code behind from my Page.aspx.vb. in my Page i have a button i want to add this function to my button onclick="refreshParent();"
View 8 Repliesi have the following function in default.aspx.....i have webusercontrol which have 10 checkboxes and 1 button .... i want when i click on button1 of user control then it can access the function of default.aspx ...page ...if i dragged the usercontrol to default.aspx
Normally if i use 10 checkboxes and 1 button in default.aspx then it works fine ... if i use 10checkboxes and 1button in usercontrol then drag that usercontrol in default.aspx then it will not work ..
[Code]....
Given the function
[code]....
When 'return false' is fired, I'm assuming that the function is stopped at that point and there's no need for exit fors and things like that?
I have more than one user control and those user controls have extenders of the ajaxcontroltoolkit. The problem is that each one has a javascript that writes "function PageLoad"... and as I have more than one user control in the same aspx, more than one of those javascript functions is written in the output. Is there anyway to combine all of them in just one function? (bear in mind that the javascript code is written within the user control and the user control doesn't know anything about what other control are in the container aspx). If I have more than one function PageLoad they will not work then, right?
View 5 RepliesIn our project WCF service is acting as our BLL.
i had scenario where i had to fill list of object class without knowing its type see code:
Added contract
[OperationContract]
dynamic GetReferenceTableData(string tableName);
method in service:
public dynamic GetReferenceTableData(string tableName)
{
try
{
dynamic tableData = ReferenceTableDAL.GetReferenceTableData(tableName);
return tableData;
}
catch (Exception ex)
{
throw;
}
}
method at DAL(ReferenceTableDAL):
public static dynamic GetReferenceTableData(string tableName)
{
Database db = DatabaseFactory.CreateDatabase(Flags.ConnectionStringKey);
DbCommand dbCommand = db.GetStoredProcCommand("USP_GETTABLEDATA");
dynamic objDynamic = null;
if (tableName.ToLower() == "a")
{
objDynamic = new List<A>();
}
else if (tableName.ToLower() == "b")
{
objDynamic = new List<B>();
}
else if (tableName.ToLower() == "c")
{
objDynamic = new List<C>();
}
try
{
db.DiscoverParameters(dbCommand);
dbCommand.Parameters["IN_TABLENAME"].Value = tableName;
DataSet dsTableData = db.ExecuteDataSet(dbCommand);
if (tableName.ToLower() == "a")
{
foreach (DataRow dataRow in dsTableData.Tables[0].Rows)
{
objDynamic.Add((A)dataRow);
}
}
else if (tableName.ToLower() == "b")
{
foreach (DataRow dataRow in dsTableData.Tables[0].Rows)
{
objDynamic.Add((B)dataRow);
}
}
else if (tableName.ToLower() == "c")
{
foreach (DataRow dataRow in dsTableData.Tables[0].Rows)
{
objDynamic.Add((C)dataRow);
}
}
}
catch (Exception ex)
{
throw;
}
return objDynamic;
}
@ Aspx
try
{
using (DataServiceRef.DataServiceClient petService = new DataServiceRef.DataServiceClient())
{
dynamic tableData = petService.GetReferenceTableData(tableName);
//tableData is null ,exception
}
}
catch (Exception ex)
{
throw;
}
There is no exception at dal or service end when i debug list gets filled ok but when returns to aspx error at aspx(no exception gets caught at @ service) but exception at aspx i.e:
Message:The underlying connection was closed: The connection was closed unexpectedly.
Stack Trace: at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Getting error calling Javsscript function from another Javascript function
[Code]....
<asp:LinkButton CssClass="button" ID="btnApply" runat="server" OnClick="btnApply_Click()" OnClientClick="Apply1('btnApply')" >
hi ihave this functin in .vb file
Protected Sub btnApply_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnApply.Click
end sub
and javascript function also in aspx
function ApplySummerization(id)
{
alert("hai");
}
I have a function in .CS file. i want to return many values fetched in the function to .aspx.cs file(both files in the same project)
How to return a values from the below function(.CS file code is as follows):
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
[Code]....
I want to pass advocates,jjj,tyear,year,petitioner1,resp1,sb etc... How can i do it??
internal static void GetUserData(int userId, out string userName,
out string userEmail, out string userPassword)
{
using (SqlConnection con = Util.GetConnection())
{
con.Open();
using (SqlCommand cmd = new SqlCommand("usp_UD_SelectById", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@UD_ID", SqlDbType.Int).Value = userId;
cmd.Parameters.Add("@UD_UserName", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@UD_Password", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@UD_Email", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
userName = Convert.ToString(cmd.Parameters["@UD_UserName"].Value);
userEmail = Convert.ToString(cmd.Parameters["@UD_Email"].Value);
userPassword = Convert.ToString(cmd.Parameters["@UD_Password"].Value);
}
}
}
and the call
string userEmail;
string userName;
string userPassword;
MemberHelper.GetUserData(userId, out userName, out userEmail, out userPassword);
Sometimes I need to get just one parameter from the out parameters, how can I call the function when I want to get just one:
string userPassword;
MemberHelper.GetUserData(userId,"","",out userPassword);
[Code]....
This method always returns '-1' (Fail) while it is expected the method return '0' (Success).
I have written an insert stored procedure which is called by my business logic layer, I want to return the new ID to the function once it has executed but i'm not sure how.
My SP uses RETURN SCOPE and when I have tested this it works but how I get that into a variable in the BLL function I don't know.
Without giving away specifics: basically, I have a bunch of users adding content to my site. What happens now is ajax sends the text to a web service which does its thing, sends the info to the DB, Sends the user an e-mail, and then returns a response to the browser to do something.
What I would like to do is change that order. I want to return a response to the browser so the user is not waiting on the e-mail to send before they get their response. Basically, I'm trying to gain every milisecond I can to quicken the response, and there's no reason for the user to wait for the server to send their e-mail before it tells them that everything worked ok. If the info went to the DB, that's all the user needs to know, they'll know the e-mail sent when it shows up in their inbox. I notice this is an issue on my local machine which has no SMTP server and can actually hang the page response up for a few extra seconds because it's throwing errors trying to send something with no SMTP server.
So, I know in my function when I say
[Code]....
it WORKS, but I want to send the e-mail after the return. Is there ANY way to get this to happen?
I am looking for a c# function to return a portion of the html. Say I have pages that render html of about 60 k in length, I want to email to users showing only the first 2k and add a link to the original page.
Sure there is a Substring function with String, but it will give me a lot of unclosed html tags.
I trying to display image in picture box. The application have two part.First part is windows application, and second part is web service (asmx).This is the code for windows application:
Public Sub PrikazSlike()
Dim p As localhost.Service1 = New localhost.Service1()
PictureBox1.Image = Image.FromStream(p.PictureShow()) [code]....
The problem is that function in web service does not return System.IO.MemoryStream data type so I getting error message can not convert:
Error 1 Value of type 'WindowsApplication1.localhost.MemoryStream' cannot be converted to 'System.IO.Stream'.
I am trying to replace the JavaScript onclick event handler in ASP.NET that is added to a button control when using validation controls. This is what is output into the HTML from ASP.NET in this scenario:
<input type="image" name="ibSubmit1" id="ibSubmit1" src="button-green-submit.gif" onclick="showProgress1();WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ibSubmit1", "", true, "Group1", "", false, false))" style="border-width:0px;" />
I have looked pretty estensively, and unfortunately there doesn't seem to be a way to modify the function server side before it is injected into the page.
Since I am developing a control and desire it to be non-invasive and self contained, and I am interested in obtaining the validationGroup parameter of the WebForm_PostBackOptions object, it seems that the easiest solution would be to use JavaScript to replace the WebForm_DoPostBackWithOptions function name with my custom wrapper function and leave all of the rest of the parameter information intact - then I can extract the information I am interested in, call my custom functions, and then forward the call on to WebForm_DoPostBackWithOptions.
NOTE: I am using jQuery to build my custom function, so if there is an easier way to do this with jQuery it is an option I will consider.
Here is the code I tried to replace the onclick event handler (not working):
$('[onclick*=WebForm_DoPostBackWithOptions]').each(function() {
var txt = this.onclick;
txt = txt + '';
txt = txt.replace('WebForm_DoPostBackWithOptions','ml_DoPostBackWithOptions');
this.onclick = eval(txt);
});
Using alert(), I verified that the text is being changed correctly, however whether or not I use the eval() function, the onclick handler doesn't seem to recognize it as JavaScript.
I thought of using a regular expression to get the validationGroup value, but this seems like it will be far more elegant and flexible if I can get it working...
Note: If there is a way for my control to interrogate the page it is on to find all of the buttons that will post back (regardless of what type of buttons they are) so I can retrieve the property server-side, this is also something I will consider.
I'm new to C# and ASP and can't seem to figure out how to write a function to return a CSS Class name.
Here's what I have so far:
In "MyWeb.master" I have a line that reads:
<asp:HyperLink ID="HyperLink1" text="xxxxx"
cssClass='<%# MyCssStyle("ddd") %>'
NavigateUrl="http://www.RDRR.com/Catalog.aspx?TribeID=1"
runat="server" />
And in "MyWeb.master.cs" I have a routine within the partial class that reads:
public string MyCssStyle(string myInput)
{
myInput = "NavigationBarUnselected";
return myInput;
}
This code does not throw an error, but neither does it return a value. What have I missed?
I have create a table and create edmx file, and I create a Stored Procedure that return a single row (select by primary key), and I want the edmx to have a function that calls that SP and return a type.
View 1 RepliesI have this java function that works great, but I need it to only return two decimal places like 333.33. Currently it returns 333.3333333333. What can I do to modify this?
plannedpmt = (pledgedamt / numberpayments)