Thursday, March 29, 2012
Pass Parameter to Javascript
function showmsgbox(chkB, somestring)
{
xState=chkB.checked;
if(xState)
{
chkB.parentElement.parentElement.style.backgroundColor='yellow';
}
else
{
chkB.parentElement.parentElement.style.backgroundColor='whitesmoke';
}
alert(somestring);
}
I need to pass the second parameter o the function from within a datagrid
like so... Only problem is I keep getting many erros with my syntax. How
can this be accomplished?...
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox ID="chkBox1" onclick="javascript:HighlightRow(this, '<%#
DataBinder.Eval(Container, "DataItem.column1") %>'');" runat="server"
autopostback="False"/>
</ItemTemplate>
</asp:TemplateColumn>
Thanks.I did it through the (gridview's) row event.
Using findcontrol and adding the onclick there.
However, a few days ago this kind of syntax was posted, i haven't tried it
yet.
<asp:ImageButton id="x" OnClientClick=<%# "menu('" + Eval("TableId") +
"');return false;"%> />
Maybe it helps?
"Jay" <msnews.microsoft.com> schreef in bericht
news:OpCSvNG9FHA.1416@.TK2MSFTNGP09.phx.gbl...
>I have javascript that accepts 2 parameters like so...
> function showmsgbox(chkB, somestring)
> {
> xState=chkB.checked;
> if(xState)
> {
> chkB.parentElement.parentElement.style.backgroundColor='yellow';
> }
> else
> {
> chkB.parentElement.parentElement.style.backgroundColor='whitesmoke';
> }
> alert(somestring);
> }
> I need to pass the second parameter o the function from within a datagrid
> like so... Only problem is I keep getting many erros with my syntax. How
> can this be accomplished?...
> <asp:TemplateColumn>
> <ItemTemplate>
> <asp:CheckBox ID="chkBox1" onclick="java script:HighlightRow(this, '<%#
> DataBinder.Eval(Container, "DataItem.column1") %>'');" runat="server"
> autopostback="False"/>
> </ItemTemplate>
> </asp:TemplateColumn>
> Thanks.
>
Here is the failing code regarding that post:
<asp:ImageButton ID="ImageButton2" runat="server"
It seems menu is a function.
"Edwin Knoppert" <info@.pbsoft.speedlinq.nl> schreef in bericht
news:dmftqs$f14$1@.azure.qinip.net...
>I did it through the (gridview's) row event.
> Using findcontrol and adding the onclick there.
> However, a few days ago this kind of syntax was posted, i haven't tried it
> yet.
> <asp:ImageButton id="x" OnClientClick=<%# "menu('" + Eval("TableId") +
> "');return false;"%> />
> Maybe it helps?
>
> "Jay" <msnews.microsoft.com> schreef in bericht
> news:OpCSvNG9FHA.1416@.TK2MSFTNGP09.phx.gbl...
>
the onclick is the serverside click. in the codebehind, you to add the
client onclick in the code behind using
checkbox.Attributes["onclick"] = value;
to add at the individual level, use the ItemDataBound Event of the repeater.
-- bruce (sqlwork.com)
"Jay" <msnews.microsoft.com> wrote in message
news:OpCSvNG9FHA.1416@.TK2MSFTNGP09.phx.gbl...
>I have javascript that accepts 2 parameters like so...
> function showmsgbox(chkB, somestring)
> {
> xState=chkB.checked;
> if(xState)
> {
> chkB.parentElement.parentElement.style.backgroundColor='yellow';
> }
> else
> {
> chkB.parentElement.parentElement.style.backgroundColor='whitesmoke';
> }
> alert(somestring);
> }
> I need to pass the second parameter o the function from within a datagrid
> like so... Only problem is I keep getting many erros with my syntax. How
> can this be accomplished?...
> <asp:TemplateColumn>
> <ItemTemplate>
> <asp:CheckBox ID="chkBox1" onclick="java script:HighlightRow(this, '<%#
> DataBinder.Eval(Container, "DataItem.column1") %>'');" runat="server"
> autopostback="False"/>
> </ItemTemplate>
> </asp:TemplateColumn>
> Thanks.
>
Pass Recordset from Web Service to Classic ASP.
datas (RecordSet). And want to retrived those data on the classic ASP.
Does any body have some example of this. How to create the Recordset in
webservice and get it at classic asp.
Thanks and Regards.Ted Ngo wrote:
> I want to use the .net Web Service to create a function and return the
> datas (RecordSet). And want to retrived those data on the classic ASP.
> Does any body have some example of this. How to create the Recordset
> in webservice and get it at classic asp.
> Thanks and Regards.
See this thread:
http://groups.google.com/group/micr...29ded2e3b036cec
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
so I using this
Or, you can send the XML of the ADO recordset back, and re-construct it
on
the client. Use Interop on the server to work with the ADO recordset.
// ON THE SERVER -- Web Service
// Add references to ADODB library
// Create a stream object
myStream = new ADODB.Stream();
// Replace the constants with their actual values
recordSet.Save(myStream, adPersistXML);
output = myStream.ReadText(adReadAll);
// Return the XML string, complete with schema
return output;
To return the recorset
and then on the asp using this to get the record set
Public Function RecordsetFromXMLString(sXML As String) As Recordset
Dim oStream As ADODB.Stream
Set oStream = New ADODB.Stream
oStream.Open
oStream.WriteText sXML 'Give the XML string to the ADO Stream
oStream.Position = 0 'Set the stream position to the start
Dim oRecordset As ADODB.Recordset
Set oRecordset = New ADODB.Recordset
oRecordset.Open oStream 'Open a recordset from the stream
oStream.Close
Set oStream = Nothing
Set RecordsetFromXMLString = oRecordset 'Return the recordset
Set oRecordset = Nothing
End Function
Is that righ?
Thanks
Yes, that's what I had in mind. Also, see Adam's last message in that
thread.
Bob
Ted Ngo wrote:
> so I using this
> Or, you can send the XML of the ADO recordset back, and re-construct
> it on
> the client. Use Interop on the server to work with the ADO recordset.
>
> // ON THE SERVER -- Web Service
> // Add references to ADODB library
>
> // Create a stream object
> myStream = new ADODB.Stream();
>
> // Replace the constants with their actual values
> recordSet.Save(myStream, adPersistXML);
> output = myStream.ReadText(adReadAll);
>
> // Return the XML string, complete with schema
> return output;
> To return the recorset
> and then on the asp using this to get the record set
> Public Function RecordsetFromXMLString(sXML As String) As Recordset
> Dim oStream As ADODB.Stream
> Set oStream = New ADODB.Stream
> oStream.Open
> oStream.WriteText sXML 'Give the XML string to the ADO Stream
> oStream.Position = 0 'Set the stream position to the start
> Dim oRecordset As ADODB.Recordset
> Set oRecordset = New ADODB.Recordset
> oRecordset.Open oStream 'Open a recordset from the stream
> oStream.Close
> Set oStream = Nothing
> Set RecordsetFromXMLString = oRecordset 'Return the recordset
> Set oRecordset = Nothing
> End Function
> Is that righ?
> Thanks
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Monday, March 26, 2012
pass text to javascript function
I found this code and I want to pass this function a value
from a dataset.
How do I do this?
<INPUT onmouseover="func()" type="button" value="Button"
<script type=text/javascript>
function func()
{
//you could put anything here, e.g. opening a window etc.
alert('Hi');
}
</script<INPUT runat="server" id="myButton" onmouseover="func()" type="button"
value="Button"
In the code behind (C#):
myButton.Attributes["onmouseover"]=String.Format("func({0})", "my text");
Eliyahu
"prav" <prav@.hotmail.com> wrote in message
news:10ca01c4d624$ae4a5410$a501280a@.phx.gbl...
> Hello,
> I found this code and I want to pass this function a value
> from a dataset.
> How do I do this?
> <INPUT onmouseover="func()" type="button" value="Button">
>
> <script type=text/javascript>
> function func()
> {
> //you could put anything here, e.g. opening a window etc.
> alert('Hi');
> }
> </script>
Eliyahu Goldin wrote:
> <INPUT runat="server" id="myButton" onmouseover="func()"
> type="button" value="Button">
> In the code behind (C#):
> myButton.Attributes["onmouseover"]=String.Format("func({0})", "my
> text");
> Eliyahu
You might want to put quotes around that text:
String.Format("func('{0}')", "my text");
(and then you could still have problems with quotes inside the string)
Hans Kesting
pass text to javascript function
I found this code and I want to pass this function a value
from a dataset.
How do I do this?
<INPUT onmouseover="func()" type="button" value="Button">
<script type=text/javascript>
function func()
{
//you could put anything here, e.g. opening a window etc.
alert('Hi');
}
</script><INPUT runat="server" id="myButton" onmouseover="func()" type="button"
value="Button">
In the code behind (C#):
myButton.Attributes["onmouseover"]=String.Format("func({0})", "my text");
Eliyahu
"prav" <prav@.hotmail.com> wrote in message
news:10ca01c4d624$ae4a5410$a501280a@.phx.gbl...
> Hello,
> I found this code and I want to pass this function a value
> from a dataset.
> How do I do this?
> <INPUT onmouseover="func()" type="button" value="Button">
>
> <script type=text/javascript>
> function func()
> {
> //you could put anything here, e.g. opening a window etc.
> alert('Hi');
> }
> </script>
>
Eliyahu Goldin wrote:
> <INPUT runat="server" id="myButton" onmouseover="func()"
> type="button" value="Button">
> In the code behind (C#):
> myButton.Attributes["onmouseover"]=String.Format("func({0})", "my
> text");
> Eliyahu
>
You might want to put quotes around that text:
String.Format("func('{0}')", "my text");
(and then you could still have problems with quotes inside the string)
Hans Kesting
Pass Value from HTML to Code Behind
receiving variable in Code Behind?
My program passes a value to a function in HTML '**** This works fine ****'
'****** CODE BEHIND ******'
Private Sub MyDataGrid(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles MyDataGrid.ItemDataBound
Dim x As Integer
For x = 0 To 1
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
e.Item.Cells(x).Attributes.Add("onclick", "sample('" & e.Item.Cells(x).Text & "')")
End If
Next
End Sub
'MY PROBLEM IS IN HERE. I want to pass a variable back to the Code Behind
'******* HTML *******'
<script language="javascript"
function sample(j)
'PROCESS j AND PASS IT BACK TO A VARIABLE IN CODE BEHIND
{
</script
i tried to make a public variable in code behind but it wont get the value passed
i think it is because of ITEMDATABOUND.
PLEASE HELP ME . . . Please show me how to make this work. . .Not sure exactly what you are trying to do but one easy way to pass values to the server is using Hidden Fields, so the idea is before posting back to the server you set the value using classic javascript and then in the server you will be able to read it either using the Request.Form collection or if you add this as a runat=server control using the Control.Value property.
So in your .aspx page, add this:
<INPUT Type="Hidden" ID="Hidden1" Name="Hidden1"
and in your javascript sample function, you can manipulate this field throught the "document" object. And then in your codebehind, you can simply retrieve the value:
string theValue=Request.Form["Hidden1"];
Pass value to function
I have this function:
Sub Add_Menu_Item(ByVal Id As String, ByVal Text() As String)
And I am calling it this way:
Add_Menu_Item("home", {"contact","contacts"})
I get this error:
Compiler Error Message: BC30201: Expression expected.
Why?
Thanks,
Miguel
You have to use it like this:
Add_Menu_Item("home", new string() {"contact","contacts"})
Saturday, March 24, 2012
Pass Variable to another function
I have a small question...Is there a way to do a postback to the same
page and pass a value to a function OnClick?
Example:
void GetCityName(string c)
{
string city = c;
}
Now I want to call this function by Doing a PostBack with a
asp:LinkButton.
So, here is the asp:LinkButton code.
<asp:LinkButton ID="mob" runat="server" Text="MOB"
OnClick="GetCityName('MOB')"></asp:LinkButton
Can this be done?
ThanksA Onclick serverside event must conform to the delegate signature of
the CommandEventHandler. You could store the value in a hidden html
input using javascript, then in your server event handler retrieve the
value by using Request.Form.GetValues.
Endo
Or store the value in a session variable.
i.e.
Session["city"] = city;
then have the event handler grab it
i.e.
city = (string)Session["city"];
<bcutting@.gmail.com> wrote in message
news:1129235285.953333.183460@.g44g2000cwa.googlegr oups.com...
> A Onclick serverside event must conform to the delegate signature of
> the CommandEventHandler. You could store the value in a hidden html
> input using javascript, then in your server event handler retrieve the
> value by using Request.Form.GetValues.
> Endo
I am total lost...
Does anyone have an example...
What I have is a map of Alabama. So now if I show Mobile, Montgomery on
the map...
and make each city as a LinkButton.
What I am doing is when the user clicks on (MOB) which is Mobile...I
have a query string that goes to a SQL Server and find data where the
city = 'mob'. I want to create a generic function that does this. So
everytime Ijust click a city all that I have to do is call the function
name and pass the city code.
Thanks
Pass Variable to another function
I have a small question...Is there a way to do a postback to the same
page and pass a value to a function OnClick?
Example:
void GetCityName(string c)
{
string city = c;
}
Now I want to call this function by Doing a PostBack with a
asp:LinkButton.
So, here is the asp:LinkButton code.
<asp:LinkButton ID="mob" runat="server" Text="MOB"
OnClick="GetCityName('MOB')"></asp:LinkButton>
Can this be done?
ThanksA Onclick serverside event must conform to the delegate signature of
the CommandEventHandler. You could store the value in a hidden html
input using javascript, then in your server event handler retrieve the
value by using Request.Form.GetValues.
Endo
Or store the value in a session variable.
i.e.
Session["city"] = city;
then have the event handler grab it
i.e.
city = (string)Session["city"];
<bcutting@.gmail.com> wrote in message
news:1129235285.953333.183460@.g44g2000cwa.googlegroups.com...
> A Onclick serverside event must conform to the delegate signature of
> the CommandEventHandler. You could store the value in a hidden html
> input using javascript, then in your server event handler retrieve the
> value by using Request.Form.GetValues.
> Endo
>
I am total lost...
Does anyone have an example...
What I have is a map of Alabama. So now if I show Mobile, Montgomery on
the map...
and make each city as a LinkButton.
What I am doing is when the user clicks on (MOB) which is Mobile...I
have a query string that goes to a SQL Server and find data where the
city = 'mob'. I want to create a generic function that does this. So
everytime Ijust click a city all that I have to do is call the function
name and pass the city code.
Thanks
Passing <%= myControl.ClientID %> into Javascript function
function, but does anyone know if it is possible to pass this value to
my Javascript function? The reason I want to do this is so I can
abstract my Javascript function out of my ASP.NET user control.
Ideally, I would like to have a function like this.
function testMe(control){
document.getElementByID(control).style = ...
// do more useful things here
// I am trying not to have to use this...
// document.getElementByID('<%=btnTest.ClientID%>').style = ...
}
I would like to be able to call it like this...
<asp:LinkButton id="btnTest" runat="server" OnClientClick="return
testMe(<%=this.ClientID%> )" text="test" />
But this does not work. If I have to keep the actual control name in
the javascript file, then my decoupling is lost. Is this approach
possible?
Thanks.Alex,
why not just pass the reference to the control itself, rather than its ID:
<asp:LinkButton id="btnTest" runat="server" OnClientClick="return
testMe(this);" text="test" />
function testMe(control){
control.style = ...
}
"Alex" wrote:
> I can successfully use <%=myControl.ClientID%> inside of a Javascript
> function, but does anyone know if it is possible to pass this value to
> my Javascript function? The reason I want to do this is so I can
> abstract my Javascript function out of my ASP.NET user control.
> Ideally, I would like to have a function like this.
> function testMe(control){
> document.getElementByID(control).style = ...
> // do more useful things here
> // I am trying not to have to use this...
> // document.getElementByID('<%=btnTest.ClientID%>').style = ...
> }
> I would like to be able to call it like this...
> <asp:LinkButton id="btnTest" runat="server" OnClientClick="return
> testMe(<%=this.ClientID%> )" text="test" />
> But this does not work. If I have to keep the actual control name in
> the javascript file, then my decoupling is lost. Is this approach
> possible?
> Thanks.
>
On Jul 26, 11:56 am, Sergey Poberezovskiy
<SergeyPoberezovs...@.discussions.microsoft.com> wrote:
> Alex,
> why not just pass the reference to the control itself, rather than its ID:
> <asp:LinkButton id="btnTest" runat="server" OnClientClick="return
> testMe(this);" text="test" />
> function testMe(control){
> control.style = ...
> }
> "Alex" wrote:
>
>
>
>
>
>
hi...
Sergey Poberezovskiy's suggested method is right...
in this way you dont have to think about client id...
Thanks
Md. Masudur Rahman (Munna)
Kaz Software Ltd.
www.kaz.com.bd
http://munnacs.110mb.com
Passing in "this" did the trick. I tried that before, but for some
reason I thought I was getting the control's ID at design time, not
the actual ASP.NET client ID at run time. This works. I appreciate the
help.
passing a collection to a function
I have finised the inbox, read, delete email etc..
Im in the process of making the "create email" or compose...
What the plan is, for people to be able to enter multiple "To:" "CC:" and "BCC:"
I have only done the "To:" field as yes, Atrax gave me the hint on how to split the emails with a ";" using split
What that did thou was place the emails into an array, which made it a pain to remove any blank emails which would cause an error...
I would always be working with strings, Below is the code that works with the "To" field
Dim arrTo(), strEmail As String
Dim j, intColCount, intEmptyColID As Integer
Dim colTo As ArrayList
Dim bolValidEmails, bolFoundInvalid As Boolean
'Dim objMsg As Object
'objMsg = Server.CreateOBject("JMail.Message")
'objMsg.Logging = true
'objMsg.Silent = true
'objMsg.From = Session("EmailAddress")
'\\\\\\\\\\\\\\\Splits the "To:" information into different emails - placing them into a collection for later use
colTo = New ArrayList
arrTo = strTo.Split(";")
For Each strEmail in arrTo
colTo.Add(trim(strEmail))
Next
'\\\\\\\\\\\\\\\Erases any empty emails out of the collection
bolValidEmails = False
bolFoundInvalid = False
intEmptyColID = -1
Do While bolValidEmails = False
For j = 0 To colTo.Count - 1
If bolFoundInvalid = False Then
If colTo(j) = "" Then
bolFoundInvalid = True
intEmptyColID = j
End If
End If
Next
If bolFoundInvalid = True Then
bolValidEmails = False
colTo.RemoveAt(intEmptyColID)
Else
bolValidEmails = True
End If
intEmptyColID = -1
bolFoundInvalid = False
Loop
'\\\\\\\\\\\\\\\Trims the Collection
colTo.TrimToSize()
What I want to do is, after I create the collection for any of the "to" "cc" and "bcc" is call that function and empty any blank emails, but I dont know how to pass the collection to the function and return the collection and continue on...
I was only using the
Dim strRandom As String
Dim objRand As New Misc
strRandom = objRand.GenerateRandNum()
objRand = Nothing
Response.Redirect("inbox.aspx?rnd=" & strRandom)
as an example of what i wanted to do as i couldn't remember the name after so many hours of programming =)...
I was asking can i use something like
Dim objChecker As New Misc
objRand.GenerateRandNum(ByRef collection name as ??)
objRand = Nothing
'continue with the rest of the email processing
do you have any code that passes a collection to a function like that? That I can look at, As I will need to be able to use the same function by multiple classes..(eg on the "reply", "Create email", "forward" class etc )
Thanks heaps
Hawk
ws abyss at infoyou can use a function with a parametere of collection as
1- dimension
private function myfunction(ByVal Arrto() As String)
or
private function myfunction(ByVal Arrto As String())
2- dimension
private function myfunction(ByVal Arrto(,) As String)
or
private function myfunction(ByVal Arrto As String(,))
Regards
Ather Ali Shaikh
"Hawk" <anonymous@.discussions.microsoft.com> wrote in message
news:13B899D4-3698-4E51-AC58-5FBE388D9C75@.microsoft.com...
> What I am doing is creating a web based email, using .net
> I have finised the inbox, read, delete email etc..
> Im in the process of making the "create email" or compose...
> What the plan is, for people to be able to enter multiple "To:" "CC:" and
"BCC:"
> I have only done the "To:" field as yes, Atrax gave me the hint on how to
split the emails with a ";" using split
> What that did thou was place the emails into an array, which made it a
pain to remove any blank emails which would cause an error...
> I would always be working with strings, Below is the code that works with
the "To" field
>
> Dim arrTo(), strEmail As String
> Dim j, intColCount, intEmptyColID As Integer
> Dim colTo As ArrayList
> Dim bolValidEmails, bolFoundInvalid As Boolean
> 'Dim objMsg As Object
> 'objMsg = Server.CreateOBject("JMail.Message")
> 'objMsg.Logging = true
> 'objMsg.Silent = true
> 'objMsg.From = Session("EmailAddress")
> '\\\\\\\\\\\\\\\Splits the "To:" information into different
emails - placing them into a collection for later use
> colTo = New ArrayList
> arrTo = strTo.Split(";")
> For Each strEmail in arrTo
> colTo.Add(trim(strEmail))
> Next
> '\\\\\\\\\\\\\\\Erases any empty emails out of the collection
> bolValidEmails = False
> bolFoundInvalid = False
> intEmptyColID = -1
> Do While bolValidEmails = False
> For j = 0 To colTo.Count - 1
> If bolFoundInvalid = False Then
> If colTo(j) = "" Then
> bolFoundInvalid = True
> intEmptyColID = j
> End If
> End If
> Next
> If bolFoundInvalid = True Then
> bolValidEmails = False
> colTo.RemoveAt(intEmptyColID)
> Else
> bolValidEmails = True
> End If
> intEmptyColID = -1
> bolFoundInvalid = False
> Loop
> '\\\\\\\\\\\\\\\Trims the Collection
> colTo.TrimToSize()
>
> What I want to do is, after I create the collection for any of the "to"
"cc" and "bcc" is call that function and empty any blank emails, but I dont
know how to pass the collection to the function and return the collection
and continue on...
> I was only using the
> Dim strRandom As String
> Dim objRand As New Misc
> strRandom = objRand.GenerateRandNum()
> objRand = Nothing
> Response.Redirect("inbox.aspx?rnd=" & strRandom)
> as an example of what i wanted to do as i couldn't remember the name after
so many hours of programming =)...
> I was asking can i use something like
> Dim objChecker As New Misc
> objRand.GenerateRandNum(ByRef collection name as ??)
> objRand = Nothing
> 'continue with the rest of the email processing
>
> do you have any code that passes a collection to a function like that?
That I can look at, As I will need to be able to use the same function by
multiple classes..(eg on the "reply", "Create email", "forward" class etc )
> Thanks heaps
> Hawk
> ws abyss at info
Wednesday, March 21, 2012
Passing a Dataset from a function in a class
Public Function GetJobTitle(ByVal Job_Title_ID As Integer, ByVal Company_ID
As Integer) As DataSet
' Setup the Stored Procedure
Dim SqlCommand As New SqlCommand
Dim SqlConnection As New SqlConnection(DataLayer.ConnectionString)
Try
SqlCommand.CommandText = "dbo.DeleteJobTitle"
SqlCommand.CommandType = System.Data.CommandType.StoredProcedure
SqlCommand.Connection = SqlConnection
' Load the Parameters
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@dotnet.itags.org.Job_Title_ID",
System.Data.SqlDbType.Int, 4)).Value = Job_Title_ID
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@dotnet.itags.org.Company_ID", System.Data.SqlDbType.Int,
4)).Value = Company_ID
' Fire the Procedure
SqlConnection.Open()
' Create a dataset
Dim da As SqlDataAdapter = New SqlDataAdapter
da.SelectCommand = SqlCommand
Dim ds As New DataSet
da.Fill(ds, "JobTitle")
Return ds
Catch ex As Exception
Throw New Exception(ex.ToString)
Finally
SqlConnection.Close()
End Try
End Function
I now have a web form called Default.aspx
How can I poplulate a Datagrid or Select box from the above function?
Datagrid1.Datasource = jobs.GetJobTitle(1,1) ?
Please help
Thanks Daren"Daren Hawes" <newsgroups@.webdesignmagic.com.au> wrote in
news:uOXyu5cVFHA.1452@.TK2MSFTNGP14.phx.gbl:
> I now have a web form called Default.aspx
> How can I poplulate a Datagrid or Select box from the above function?
> Datagrid1.Datasource = jobs.GetJobTitle(1,1) ?
Yes exactly - but just remember to call Datagrid1.databind.
--
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Passing a Dataset from a function in a class
Public Function GetJobTitle(ByVal Job_Title_ID As Integer, ByVal Company_ID
As Integer) As DataSet
' Setup the Stored Procedure
Dim SqlCommand As New SqlCommand
Dim SqlConnection As New SqlConnection(DataLayer.ConnectionString)
Try
SqlCommand.CommandText = "dbo.DeleteJobTitle"
SqlCommand.CommandType = System.Data.CommandType.StoredProcedure
SqlCommand.Connection = SqlConnection
' Load the Parameters
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
False, CType(0, Byte), CType(0, Byte), "",
System.Data.DataRowVersion.Current, Nothing))
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@dotnet.itags.org.Job_Title_ID",
System.Data.SqlDbType.Int, 4)).Value = Job_Title_ID
SqlCommand.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@dotnet.itags.org.Company_ID", System.Data.SqlDbType.Int,
4)).Value = Company_ID
' Fire the Procedure
SqlConnection.Open()
' Create a dataset
Dim da As SqlDataAdapter = New SqlDataAdapter
da.SelectCommand = SqlCommand
Dim ds As New DataSet
da.Fill(ds, "JobTitle")
Return ds
Catch ex As Exception
Throw New Exception(ex.ToString)
Finally
SqlConnection.Close()
End Try
End Function
I now have a web form called Default.aspx
How can I poplulate a Datagrid or Select box from the above function?
Datagrid1.Datasource = jobs.GetJobTitle(1,1) ?
Please help
Thanks Daren"Daren Hawes" <newsgroups@.webdesignmagic.com.au> wrote in
news:uOXyu5cVFHA.1452@.TK2MSFTNGP14.phx.gbl:
> I now have a web form called Default.aspx
> How can I poplulate a Datagrid or Select box from the above function?
> Datagrid1.Datasource = jobs.GetJobTitle(1,1) ?
Yes exactly - but just remember to call Datagrid1.databind.
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
[url]http://members.ebay.com/aboutme/
Passing a reference to a component
All,
I want to be able to pass a component referance to a function e.g I dont know what component it will be but need to bind data to it. See code
void BindDataToControl(Object paramControlName,String QueryString){
Response.Write("Object = "+ paramControlName);
// I have a class that gets the data and returns a recordset fine
//open DB and get data here
// just need help with getting the paramater bound to the data
paramControlName.DataSource = RSMenuData;
paramControlName.DataBind();
//close data base connection and clean up here
}
Any ideas how I can get over this?? ANy better ideas??
Thanks
ED BOC
Not sure, but maybe this topic will help:
http://forums.asp.net/thread/1215456.aspx
Thanks I will give it a go and post the results (if i get it working!)
Cheers
Passing a string to a client side function
1. Put the xml string in a textbox control (and set the display style to
none using css stylesheet) then simply reference the value of your textbox
control, to get the XML string.
2. (Probably the better one) Add a hidden input field to your form, set the
runat attribute to server and then simply assign your XML string as the
value of the hidden input field from within your code behind. Using this
method the encoding is taken care of for you as the whole lot will be html
encoded. (I pretty sure this should then work fine, but I may be wrong!!)
Hope one of the above works for you.
Matt
http://www.3internet.com
"Jorell" <anonymous@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:70A4100B-D764-4FEA-B111-A5B9AE9E6529@dotnet.itags.org.microsoft.com...
> Hi everyone,
> I have an XML that I create on the fly. I need to pass this to a
Javascript function and I do it in this way:
> Page.RegisterStartupScript("Test", "<script
language=""javascript"">printHidden('" & XML & "')</script>")
> This works however if you encase the XML in single quotes then there could
possibly a terminating ' in the XML and on the other hand if you encase the
XML in double quotes and there is a single " in the XML...this becomes the
terminator and the client side throws an error: Unterminated string constant
> The user enters the information the XML is built with and we must allow
them the ability to enter these any characters.
> What I need to do is encode the string server side before it is passed and
then unencode it on the client.
> I have attempted to use Regex.Escape on the Server then unescape() on the
client with no luck.
> Any ideas/suggestions would be great! Thank you
> JorellJorell,
If you use the option of outputting your text to a form variable you should
not need to use escape characters at all. If you just leave the string
exactly as you want it to appear and output it to the form variables, when
you retrieve the value you should see exactly what you are looking for. Or
is there something that I am missing as to why do you need to put escape
characters in?
Matt
http://www.3internet.com
"Jorell" <anonymous@.discussions.microsoft.com> wrote in message
news:B8A31C70-DF4A-49D1-AB87-CA7E3AF4487D@.microsoft.com...
> Hi there. Thank you for the suggestion. I tried this as I figured the same
however the value, innerText and innerHtml etc properties all return the
HTML but with the escape characters ie. \"
> This still causes and issue and without actually doing a loop to look for
escape characters and replacing them...but there is a possibly of not
catching all of them.
> Essentially I am just writing this HTML to a div using the document.write
method and then printing the div using execWB.
> Any ideas would be great thank you!
> Jorell
Hi there Matt
I actually don't want the characters in the string. What I have is Complex HTML that I have created in a server function
I have a js function which needs to take that HTML and write it to the Body of an IFrame that it creates. ( that can't be changed) So basically what I need to be able to do is end up with a variable inside that js function which is straight HTML no escapes.
Mostly the problem is if you use textboxes of any sort...the innerHtml, innerText, Text, or value fields always return the value with escape charaters when accessing them from the client. I am not sure why
So no matter what I put the HTML in, it adds escape chars
Any ideas? I appologize if it is unclear! Thank yo
Jorell
Passing a string to a client side function
character (e.g. \' or \"). The backslash is the escape character in
JavaScript.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Jorell" <anonymous@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:70A4100B-D764-4FEA-B111-A5B9AE9E6529@dotnet.itags.org.microsoft.com...
> Hi everyone,
> I have an XML that I create on the fly. I need to pass this to a
Javascript function and I do it in this way:
> Page.RegisterStartupScript("Test", "<script
language=""javascript"">printHidden('" & XML & "')</script>")
> This works however if you encase the XML in single quotes then there could
possibly a terminating ' in the XML and on the other hand if you encase the
XML in double quotes and there is a single " in the XML...this becomes the
terminator and the client side throws an error: Unterminated string constant
> The user enters the information the XML is built with and we must allow
them the ability to enter these any characters.
> What I need to do is encode the string server side before it is passed and
then unencode it on the client.
> I have attempted to use Regex.Escape on the Server then unescape() on the
client with no luck.
> Any ideas/suggestions would be great! Thank you
> JorellI agree however I was kind of looking at that as a last resort. If possible I was hoping there was functions on both sides that I had missed that would take care of this for me. Any chance this is possible? Thank you again
Jorell
Passing a struct to a function
I'm attempting to pass a structure to a function. The structure definition in the .aspx file and the dll are indentical. The approach looks correct, but I get this error:
Value of type 'ASP.processing_aspx.transDetails' cannot be converted to 'app.Settle.transDetails'.
Is this possible or is there a better method of passing a large number of parameters to a function?
The submitting code:
<script runat="server" language="VB"
Structure authResultsStruct
Dim Approved As Integer
Dim ErrorMsg As String
End Structure
Structure transDetails
Dim ClientID As Integer
Dim CardName As String
Dim CardNumber AS String
Dim ExpDate AS String
Dim Amount AS Double
Dim Address AS String
Dim Stripe1 AS String
Dim Stripe2 AS String
Dim Invoice AS String
Dim Zip AS String
Dim BankAccount AS String
Dim RoutingNumber AS String
Dim Created AS String
Dim PaymentType AS Integer
End Structure
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim payment AS transDetails
payment.ClientID = Request.Form("ClientID")
payment.CardName = Request.Form("CardName")
payment.CardNumber = Request.Form("CardNumber")
payment.ExpDate = Request.Form("ExpDate")
payment.Amount = Request.Form("Amount")
payment.Address = "1234"
payment.Stripe1 = Request.Form("Stripe1")
payment.Stripe2 = Request.Form("Stripe2")
payment.Invoice = Request.Form("Invoice")
payment.Zip = Request.Form("Zip")
payment.BankAccount = Request.Form("BankAccount")
payment.RoutingNumber = Request.Form("RoutingNumber")
payment.Created = Request.Form("Created")
payment.PaymentType = Request.Form("PaymentType")
Dim results AS authResultsStruct
Dim auth As New Settle()
'Dim myDataGrid
results = auth.Authorize( payment ) As authResultsStruct
Console.WriteLine(results.Status)
Console.WriteLine(result.ErrMsg)
End Sub
</script
Here is the function with struct definition:
Structure transDetails
Dim ClientID As Integer
Dim CardName As String
Dim CardNumber As String
Dim ExpDate As String
Dim Amount As Double
Dim Address As String
Dim Stripe1 As String
Dim Stripe2 As String
Dim Invoice As String
Dim Zip As String
Dim BankAccount As String
Dim RoutingNumber As String
Dim Created As String
Dim PaymentType As Integer
End Structure
Public Function Authorize(ByVal payment As transDetails) As authResultsStructJust because your type definitions are identical doesn't make the compiler think its dealing with the same types. Put the structure definition in a common code file in the app. That way the page and the code behind know they are dealing with the same type definition.
That's sounds like what I need to do. Is there a way to store data definitions so both aspx and dlls can share it?? I'm new to .net.
Thanks
fishin
Sure, define the struct in the dll and set a reference to the DLL in your project with the ASPX pages.
I'm not sure how to do that, can you show me the syntax?
Les
You do it in the GUI. Open your web project with the ASPX pages and then add your DLL project. Click on references in solution explorer -> Right Click ADD Reference click on Projects and then set the reference. Alternatively you could sign the DLL and then install it in the GAC and set a reference to it. Either way could be appropriate if you are using the DLL as a global object for several projects.
Passing a UserControl as a parameter in ASP.NET 2
I have a few user controls which I would like to pass to a function which is not on the page the usercontrols have been placed in.
The function is in the App_Code directory so I can access it from anywhere in the project but I can't refer to the user control in the parameters of the function, therefore I can't access the usercontrol.
I'm not allowed to place the UserControl in the App_Code directory, so how can I create an instance of it?
Do you have control of the server where the app is going to be deployed ?ie is it for an in house development or are you going to upload it to a public server ?
i ask coz if you have control of the server one way around the problem is to
make a dll (class) and by putting the code in the class your program will be able to access the code
Mark
Thanks Mark, will do that by building a dll. Only thing is I'm surprised that there is no way to do this using the ASP.NET 2 development model - the App_Code directory was supposed to replace the procedure of building and referencing dll's.
Passing a value from a class method to a function in start page and back to class
Hi,
I have an a one dimensional generated in one of the function of a class which I developed. I need to know how to perform the following:
1) Pass the value to the start page from the class method (this part is done).
2) Pass the value back again to another method of the same class from the start page.
Friday, March 16, 2012
Passing a value to a JavaScript function from the database
Form.
I haven't had any luck.
Can this be done?
I need to get a value from a database and send it to the JavaScript
function.
Thanks,
Scott Natwicklots of ways:
in the aspx page:
<script>
var myValue = ' <%= getValue() %>';
</script>
or in the code behind
RegisterHiddenField("myValue",getValue();
and have the javascript reference the hidden field. you can register a
script block. if you need it at runtime, the javascript can post to a hidden
iframe/frame.
-- bruce (sqlwork.com)
"Scott Natwick" <nospam@.yahoo.com> wrote in message
news:ncWdnVyYIZbz79LcRVn-hw@.comcast.com...
> I'm trying to pass a value to initialize a JavaScript function from inside
a
> Form.
> I haven't had any luck.
> Can this be done?
> I need to get a value from a database and send it to the JavaScript
> function.
> Thanks,
> Scott Natwick
>
Hi Scott,
Have you had a chance to check bruce's suggestions or have you got any
further ideas on this issue? If you need any further assistance, please
feel free to post here.Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Hi Steven,
Thanks for following up. I believe I have it working now, using the prior
suggestion.
On the C# side, my code looks roughly like this:
String scriptString = "<script language=JavaScript> ";
scriptString += "var ... ";
scriptString += "function FunctionName() {... document.Form1.strValue1.value
...}";
scriptString += "</script> ";
RegisterHiddenField("strValue1", "...");
RegisterHiddenField("strValue2", "...");
RegisterStartupScript("startup", scriptString);
It tests Ok, but I haven't put it into production yet.
Regards,
Scott
"Steven Cheng[MSFT]" <v-schang@.online.microsoft.com> wrote in message
news:qPlTs2UoEHA.2640@.cpmsftngxa06.phx.gbl...
> Hi Scott,
> Have you had a chance to check bruce's suggestions or have you got any
> further ideas on this issue? If you need any further assistance, please
> feel free to post here.Thanks.
>
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
Thanks for your followup Scott!
Anyway, if you have any problems in the future, please feel free to post
here. Thanks.
Have a good day!
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Passing a value to a JavaScript function from the database
Thanks for following up. I believe I have it working now, using the prior
suggestion.
On the C# side, my code looks roughly like this:
String scriptString = "<script language=JavaScript> ";
scriptString += "var ... ";
scriptString += "function FunctionName() {... document.Form1.strValue1.value
...}";
scriptString += "</script> ";
RegisterHiddenField("strValue1", "...");
RegisterHiddenField("strValue2", "...");
RegisterStartupScript("startup", scriptString);
It tests Ok, but I haven't put it into production yet.
Regards,
Scott
"Steven Cheng[MSFT]" <v-schang@dotnet.itags.org.online.microsoft.com> wrote in message
news:qPlTs2UoEHA.2640@dotnet.itags.org.cpmsftngxa06.phx.gbl...
> Hi Scott,
> Have you had a chance to check bruce's suggestions or have you got any
> further ideas on this issue? If you need any further assistance, please
> feel free to post here.Thanks.
>
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)Thanks for your followup Scott!
Anyway, if you have any problems in the future, please feel free to post
here. Thanks.
Have a good day!
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)