Showing posts with label function. Show all posts
Showing posts with label function. Show all posts

Thursday, March 29, 2012

passing values between aspx.vb pages

About javascript window.opener. How do I pass values from source.vb to object.vb if I use window.opener("target.aspx") in a javascript function? I want to use a separate .js file for this purpose.

My code looks something like this.

'Source.aspx
<script ... src="http://pics.10026.com/?src=scripts.js"
<a onclick="newwindow()">text</a
'Source.aspx.vb

variable1 as String
variable2 as Integer

'scripts.js
function newwindow() {
myWin = opener("target.aspx");
}

'Target.aspx.vb

variabletarget1 as String
variabletarget2 as Integer

So, I would like to set variabletarget1 = variable1 and variabletarget2 = variable2 in the process. I am not using frames or iframes. MSDN says that window.opener works only in <frame> or <iframe> pages.

How to do this with javascript?

HenrixHi Henrix,
Somethig like this:


'Source.aspx
<script ... src="http://pics.10026.com/?src=scripts.js"
<a runat="server">text</a
'Source.aspx.vb

variable1 as String
variable2 as Integer
...

a.Attributes.Add("onclick", "newwindow('"& variable1 & "'," & variable2 & ")"

'scripts.js
function newwindow(variable1, variable2) {
myWin = opener("target.aspx?variable1="+variable1+"&variable2="+variable2);
}

'Target.aspx.vb

variabletarget1 as String
variabletarget2 as Integer
...
variabletarget1 = Request.QueryString("variable1")
variabletarget2 = Int32.Parse(Request.QueryString("variable2"))

Monday, March 26, 2012

passing variable from code behind to function in javascript

Just wondering if someone could provide an example of passing a variable from
the code behind to javascript in vb. I want to have one control have focus
with the page loading with one condition and have another control with focus
after the page loads from a different condition. A gets set in the code
aspx.vb file and the script might look something like,
<script language="javascript">
function DoHighlight(a)
{
if a = 1 {
document.Form1.dr_lst_system.focus();
}
else
{
Form1.textbox1.focus();
}
}
</script
thanks.
--
Paul G
Software engineer.Hi Paul,

It is impossible to pass a variable value from the server to the client.
Server-side code executes on the server. Client-side code executes on the
client.

That said, it is certainly possible to WRITE client-side scripting code
(which will be executed on the client) dynamically from the server side.
That is what you need to do.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Paul" <Paul@.discussions.microsoft.com> wrote in message
news:1BB64CF9-9547-4DF0-9556-E2F88CE79ECA@.microsoft.com...
> Just wondering if someone could provide an example of passing a variable
> from
> the code behind to javascript in vb. I want to have one control have
> focus
> with the page loading with one condition and have another control with
> focus
> after the page loads from a different condition. A gets set in the code
> aspx.vb file and the script might look something like,
> <script language="javascript">
> function DoHighlight(a)
> {
> if a = 1 {
> document.Form1.dr_lst_system.focus();
> }
> else
> {
> Form1.textbox1.focus();
> }
> }
> </script>
>
> thanks.
> --
> Paul G
> Software engineer.
Paul,

This is normally done with hidden input controls. Put a line

<input type=hidden runat=server id=inhA
in the .aspx file. If you switch from Html view to Design and back, you will
find in the code-behind a definition for inhA as an obyect of type
System.Web.UI.HtmlControls.HtmlInputHidden.

You can now set inhA.Value="1" on server side and check if (inhA.value ==
"1") on client side.

Eliyahu

"Paul" <Paul@.discussions.microsoft.com> wrote in message
news:1BB64CF9-9547-4DF0-9556-E2F88CE79ECA@.microsoft.com...
> Just wondering if someone could provide an example of passing a variable
from
> the code behind to javascript in vb. I want to have one control have
focus
> with the page loading with one condition and have another control with
focus
> after the page loads from a different condition. A gets set in the code
> aspx.vb file and the script might look something like,
> <script language="javascript">
> function DoHighlight(a)
> {
> if a = 1 {
> document.Form1.dr_lst_system.focus();
> }
> else
> {
> Form1.textbox1.focus();
> }
> }
> </script>
>
> thanks.
> --
> Paul G
> Software engineer.
Hi thanks for the response. Here is what I have but it does not seem to be
working. In the Java script I have
<form id="Form1" method="post" runat="server">
<input type="hidden" runat="server" id="inhA" NAME="inhA">
<script language="javascript" event="onload" for="window">
if (inhA.value == 0)
{Form1.dr_tx_names.focus();}
if (inhA.value == 1)
{Form1.dr_lst_system.focus();}
</script>and in the aspx.vb file I have
in page load event
If Not Page.IsPostBack Then 'only first time page loads
Me.inhA.Value = 0
and in a dropdown event select-causes the page to reload I have
Me.inhA.Value = 1
**************so I want one control two have focus if inhA = 0 and the other
to have focus if inhA = 1.
thanks for the information.
--
Paul G
Software engineer.

"Eliyahu Goldin" wrote:

> Paul,
> This is normally done with hidden input controls. Put a line
> <input type=hidden runat=server id=inhA>
> in the .aspx file. If you switch from Html view to Design and back, you will
> find in the code-behind a definition for inhA as an obyect of type
> System.Web.UI.HtmlControls.HtmlInputHidden.
> You can now set inhA.Value="1" on server side and check if (inhA.value ==
> "1") on client side.
> Eliyahu
> "Paul" <Paul@.discussions.microsoft.com> wrote in message
> news:1BB64CF9-9547-4DF0-9556-E2F88CE79ECA@.microsoft.com...
> > Just wondering if someone could provide an example of passing a variable
> from
> > the code behind to javascript in vb. I want to have one control have
> focus
> > with the page loading with one condition and have another control with
> focus
> > after the page loads from a different condition. A gets set in the code
> > aspx.vb file and the script might look something like,
> > <script language="javascript">
> > function DoHighlight(a)
> > {
> > if a = 1 {
> > document.Form1.dr_lst_system.focus();
> > }
> > else
> > {
> > Form1.textbox1.focus();
> > }
> > }
> > </script>
> > thanks.
> > --
> > Paul G
> > Software engineer.
>
On Wed, 29 Jun 2005 11:02:04 -0700, Paul wrote:

> Just wondering if someone could provide an example of passing a variable from
> the code behind to javascript in vb. I want to have one control have focus
> with the page loading with one condition and have another control with focus
> after the page loads from a different condition. A gets set in the code
> aspx.vb file and the script might look something like,
> <script language="javascript">
> function DoHighlight(a)
> {
> if a = 1 {
> document.Form1.dr_lst_system.focus();
> }
> else
> {
> Form1.textbox1.focus();
> }
> }
> </script>
>
> thanks.
Something like
if(<%=a%> = 1) will work (a is a server-side variable)
ok thanks for the information.
--
Paul G
Software engineer.

"intrader" wrote:

> On Wed, 29 Jun 2005 11:02:04 -0700, Paul wrote:
> > Just wondering if someone could provide an example of passing a variable from
> > the code behind to javascript in vb. I want to have one control have focus
> > with the page loading with one condition and have another control with focus
> > after the page loads from a different condition. A gets set in the code
> > aspx.vb file and the script might look something like,
> > <script language="javascript">
> > function DoHighlight(a)
> > {
> > if a = 1 {
> > document.Form1.dr_lst_system.focus();
> > }
> > else
> > {
> > Form1.textbox1.focus();
> > }
> > }
> > </script>
> > thanks.
> Something like
> if(<%=a%> = 1) will work (a is a server-side variable)

Saturday, March 24, 2012

passing variables from javascript to ASP code

Hi there,

I was wondering if anyone can tell me a way of passing variables through a javascript function, to a visual basic function, by any means.

However I would like to be able to do this without reloading the page, for aesthetics sakes

cheers Neilhello:

You can't pass javascript variables to ASP functions. The ASP functions run server-side and have completed their execution once the page has loaded and the javascript is ready to be run.

Also, you might do the following:

It's easy to use the value of a VBScript variable in java_script_:
document.writeln('<%= MyVBScriptVariable %>');

Or here is an example which puts the value of a VBScript variable into a JavaScript alert box:
Response.Write "<script language='JavaScript'>alert('The value is " & MyVBScriptVariable & "');</script>"

But to send the value of a JavaScript variable to VBScript, well that's another story. You could have the JavaScript fill in a hidden form field and then post the form. That way VBScript can pick up the value of the hidden form field with Request.Form("MyFieldName").

try any of these.

regards !!!!
Depending on what your application needs to do with the variables, you could use an IFRAME and have the javascript function submit a form or call a url with a querystring in the IFRAME. Resulting page can return any results you need to use to update client side controls on your page.

Also, if your pages are taking too long to load on postbacks make sure you have SmartNavigation set to true in your page.

Hope this helps.
Hello!

You can use Web services from JavaScript, so write a Web service(th actual function on VB) and call it from JavaScript with parameter you want to pass to VB function.

Hope this helps
I'm not sure of the specifics of what you are trying to do, but to pass strings to code-behind functions, all you have to do is set the html web controls to runat=server. For instance, we use a javascript popup window(widow.open(page.html,windowname,location)) to retrieve comments on our aspx pages. We use a hidden form control(set runat=server) to retrieve the information when the page is posted back. Of course this probably won't fit your need, but you can do it.
in the end i put variables into a js function call in a template on a datalist, then saved the variable in a cookie, which I then requested from the vb code.

thanks for the help though i will look at this post later to take it in properly :)

Friday, March 16, 2012

Password Answer

Hello,
How can I get the Password Answer string on Asp.NET 2.0 Membership?
I want to display it but I can't find the function to get it.
Thanks,
MiguelOn Jun 26, 8:21 pm, shapper <mdmo...@.gmail.com> wrote:
> Hello,
> How can I get the Password Answer string on Asp.NET 2.0 Membership?
> I want to display it but I can't find the function to get it.
> Thanks,
> Miguel
hi...
so far i tried few times but didn't succeed
if (Page.User.Identity.IsAuthenticated)
{
System.Web.Security.MembershipUser user =
System.Web.Security.Membership.GetUser(Page.User.Identity.Name);
string question = user.PasswordQuestion;
}
using this i was able to get user info but not yet the answer in clear
text format...
then i look in to the ASPNETDB.MDF database in table aspnet_membership
table PasswordAnswer column keep the data ... but its encripted...
perhaps you can took a attempt to write your own fucntion to get the
answer...
Thanks
Masudur
http://munnacs.110mb.com
By default, you are dealing with one way hashes in Membership. Even if you
use AES instead, via config, you will have to deal with the constraints of
the system or write your own custom Membership Provider.
There are certain elements you can hit with configuration alone.
At present, I know of no way to pull the info you want from the standard
provider, due to security constraints. It can be reverse engineered, but the
object model is fairly deep.
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)
****************************************
********
Think outside the box!
****************************************
********
"shapper" <mdmoura@.gmail.com> wrote in message
news:1182867663.395933.115720@.u2g2000hsc.googlegroups.com...
> Hello,
> How can I get the Password Answer string on Asp.NET 2.0 Membership?
> I want to display it but I can't find the function to get it.
> Thanks,
> Miguel
>

Password Answer

Hello,

How can I get the Password Answer string on Asp.NET 2.0 Membership?
I want to display it but I can't find the function to get it.

Thanks,
MiguelBy default, you are dealing with one way hashes in Membership. Even if you
use AES instead, via config, you will have to deal with the constraints of
the system or write your own custom Membership Provider.

There are certain elements you can hit with configuration alone.

At present, I know of no way to pull the info you want from the standard
provider, due to security constraints. It can be reverse engineered, but the
object model is fairly deep.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
"shapper" <mdmoura@.gmail.comwrote in message
news:1182867663.395933.115720@.u2g2000hsc.googlegro ups.com...

Quote:

Originally Posted by

Hello,
>
How can I get the Password Answer string on Asp.NET 2.0 Membership?
I want to display it but I can't find the function to get it.
>
Thanks,
Miguel
>