Thursday, March 29, 2012
Pass Parameter As DataGridItemEventArgs
calls a sub named 'BindData'. This sub first finds a Label which exists
in the ItemTemplate of the TemplateColumn of the DataGrid & does some
work with the Label.
Sub BindData(obj As Object, ea As DataGridItemEventArgs)
Dim lbl As Label
If (ea.Item.ItemType = ListItemType.Item Or ea.Item.ItemType =
ListItemType.AlternatingItem) Then
lbl = ea.Item.FindControl("lblAcre")
...
...
End If
End Sub
The Button has the Click event which invokes a sub named 'SubmitPage'.
Sub SubmitPage(obj As Object, ea As EventArgs)
...
End Sub
Now I did like the 'SubmitPage' sub to invoke the 'BindData' sub. How
do I accomplish this? In other words, what parameters do I pass from
the 'SubmitPage' sub to the 'BindData' sub which the latter expects?You can't get DataGridItemEventArgs in SubmitPage (it is event argument data
type specific to a event, so it's not even wise to use as input to a
method), but you can loop through the DataGrid manually.
Sub SubmitPage(obj As Object, ea As EventArgs)
For each dgitem As DataGridItem in DataGrid1.Items
Dim lbl As Label=Nothing
If (dgitem.ItemType = ListItemType.Item Or dgitem.ItemType =
ListItemType.AlternatingItem) Then
lbl = dgitem.FindControl("lblAcre")
'Do something with the Label
End If
Next
End Sub
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
<rn5a@.rediffmail.com> wrote in message
news:1165068166.263744.157190@.l12g2000cwl.googlegroups.com...
>A Form has a DataGrid & a Button. The DataGrid's ItemDataBound event
> calls a sub named 'BindData'. This sub first finds a Label which exists
> in the ItemTemplate of the TemplateColumn of the DataGrid & does some
> work with the Label.
> Sub BindData(obj As Object, ea As DataGridItemEventArgs)
> Dim lbl As Label
> If (ea.Item.ItemType = ListItemType.Item Or ea.Item.ItemType =
> ListItemType.AlternatingItem) Then
> lbl = ea.Item.FindControl("lblAcre")
> ....
> ....
> End If
> End Sub
> The Button has the Click event which invokes a sub named 'SubmitPage'.
> Sub SubmitPage(obj As Object, ea As EventArgs)
> ....
> End Sub
> Now I did like the 'SubmitPage' sub to invoke the 'BindData' sub. How
> do I accomplish this? In other words, what parameters do I pass from
> the 'SubmitPage' sub to the 'BindData' sub which the latter expects?
>
Thanks, Teemu...that's exactly what I was looking out for
Teemu Keiski wrote:
> You can't get DataGridItemEventArgs in SubmitPage (it is event argument da
ta
> type specific to a event, so it's not even wise to use as input to a
> method), but you can loop through the DataGrid manually.
> Sub SubmitPage(obj As Object, ea As EventArgs)
>
> For each dgitem As DataGridItem in DataGrid1.Items
> Dim lbl As Label=Nothing
> If (dgitem.ItemType = ListItemType.Item Or dgitem.ItemType =
> ListItemType.AlternatingItem) Then
> lbl = dgitem.FindControl("lblAcre")
> 'Do something with the Label
> End If
> Next
> End Sub
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
> <rn5a@.rediffmail.com> wrote in message
> news:1165068166.263744.157190@.l12g2000cwl.googlegroups.com...
Pass Parameter As DataGridItemEventArgs
calls a sub named 'BindData'. This sub first finds a Label which exists
in the ItemTemplate of the TemplateColumn of the DataGrid & does some
work with the Label.
Sub BindData(obj As Object, ea As DataGridItemEventArgs)
Dim lbl As Label
If (ea.Item.ItemType = ListItemType.Item Or ea.Item.ItemType =
ListItemType.AlternatingItem) Then
lbl = ea.Item.FindControl("lblAcre")
....
....
End If
End Sub
The Button has the Click event which invokes a sub named 'SubmitPage'.
Sub SubmitPage(obj As Object, ea As EventArgs)
....
End Sub
Now I did like the 'SubmitPage' sub to invoke the 'BindData' sub. How
do I accomplish this? In other words, what parameters do I pass from
the 'SubmitPage' sub to the 'BindData' sub which the latter expects?You can't get DataGridItemEventArgs in SubmitPage (it is event argument data
type specific to a event, so it's not even wise to use as input to a
method), but you can loop through the DataGrid manually.
Sub SubmitPage(obj As Object, ea As EventArgs)
For each dgitem As DataGridItem in DataGrid1.Items
Dim lbl As Label=Nothing
If (dgitem.ItemType = ListItemType.Item Or dgitem.ItemType =
ListItemType.AlternatingItem) Then
lbl = dgitem.FindControl("lblAcre")
'Do something with the Label
End If
Next
End Sub
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
<rn5a@.rediffmail.comwrote in message
news:1165068166.263744.157190@.l12g2000cwl.googlegr oups.com...
Quote:
Originally Posted by
>A Form has a DataGrid & a Button. The DataGrid's ItemDataBound event
calls a sub named 'BindData'. This sub first finds a Label which exists
in the ItemTemplate of the TemplateColumn of the DataGrid & does some
work with the Label.
>
Sub BindData(obj As Object, ea As DataGridItemEventArgs)
Dim lbl As Label
>
If (ea.Item.ItemType = ListItemType.Item Or ea.Item.ItemType =
ListItemType.AlternatingItem) Then
lbl = ea.Item.FindControl("lblAcre")
....
....
End If
End Sub
>
The Button has the Click event which invokes a sub named 'SubmitPage'.
>
Sub SubmitPage(obj As Object, ea As EventArgs)
....
End Sub
>
Now I did like the 'SubmitPage' sub to invoke the 'BindData' sub. How
do I accomplish this? In other words, what parameters do I pass from
the 'SubmitPage' sub to the 'BindData' sub which the latter expects?
>
Thanks, Teemu...that's exactly what I was looking out for
Teemu Keiski wrote:
Quote:
Originally Posted by
You can't get DataGridItemEventArgs in SubmitPage (it is event argument data
type specific to a event, so it's not even wise to use as input to a
method), but you can loop through the DataGrid manually.
>
Sub SubmitPage(obj As Object, ea As EventArgs)
>
>
For each dgitem As DataGridItem in DataGrid1.Items
>
Dim lbl As Label=Nothing
>
If (dgitem.ItemType = ListItemType.Item Or dgitem.ItemType =
ListItemType.AlternatingItem) Then
lbl = dgitem.FindControl("lblAcre")
'Do something with the Label
End If
>
Next
>
End Sub
>
>
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
>
<rn5a@.rediffmail.comwrote in message
news:1165068166.263744.157190@.l12g2000cwl.googlegr oups.com...
Quote:
Originally Posted by
A Form has a DataGrid & a Button. The DataGrid's ItemDataBound event
calls a sub named 'BindData'. This sub first finds a Label which exists
in the ItemTemplate of the TemplateColumn of the DataGrid & does some
work with the Label.
Sub BindData(obj As Object, ea As DataGridItemEventArgs)
Dim lbl As Label
If (ea.Item.ItemType = ListItemType.Item Or ea.Item.ItemType =
ListItemType.AlternatingItem) Then
lbl = ea.Item.FindControl("lblAcre")
....
....
End If
End Sub
The Button has the Click event which invokes a sub named 'SubmitPage'.
Sub SubmitPage(obj As Object, ea As EventArgs)
....
End Sub
Now I did like the 'SubmitPage' sub to invoke the 'BindData' sub. How
do I accomplish this? In other words, what parameters do I pass from
the 'SubmitPage' sub to the 'BindData' sub which the latter expects?
Monday, March 26, 2012
pass url parameter
I want to pass a URL parameter from a hyperlinked column in my datagrid to a data list on another page.
How do I construct the select statement for the datalist page please?
Cheers,
JbDo you mean you want the hyperlink URL to be something like:
/SomeDir/SomePage.aspx?ID=TheValueFromSomeDataSourceField
If so, use a HyperLinkColumn. Set its DataNavigateUrlField to the
DataSource field from where you want the databound data to come from.
Then, set the DataNavigateUrlFormatString to:
"/SomeDir/SomePage.aspx?ID={0}"
Essentially, put {0} in the string wherever you want the actual
database value to appear.
(copy and paste from a scott mitchell usenet posting.. ;-).. )
henkm.
Thanks for the reply but i meant on the other page.
select * from tbltable where class_ID = ??
cheers,
JB
The post var can be retrieved with(c#):
So, you sql is going to be something like:
string sqlSelect = "select * from tbltable where class_ID = " + Request.QueryString["ID"];
is this wat you wanted to see, or do your mean the full page code to retrieve the data and show it?
Careful with that, it is wide open to Sql Injection attacks: what happens if I call youpageurl.aspx?ID=1;delete * from tbltable ?
Well, you lose all your data...
Please consider the use of the SqlParameter object to securely build your Sql queries.
bleroy,
Thanks for pointing this out.
Do you know of any good articles or examples of using the sql parameter object for this case?
Thanks all,
JB
Sure,http://samples.gotdotnet.com/quickstart/aspplus/doc/webdataaccess.aspx#param should be a good start.
What if you want to pass 2 parameter in the DataNavigateURLFormatString like:
/SomeDir/SomePage.aspx?id={0}&id2={1}
Where will you put the second field?
Pass Username and Pwd to database query in WebMartix?
I have inserted a couple of label.texts to verify the variable make the second page.
How do I get the query to limit the return to only the records matching the UserName & Pwd combination?
Thanks,
ScottYou don't really want to pass the password around your site. And hopefully you're not allowing multiple duplicate usernames as long as the password is different.
If you're using asp.net authentication then it's somewhat safe to assume that the username is valid once they're logged in.
I.E. on your login page you set an authorization cookie.
On your details page you access their username via this cookie and use that as a parameter to your stored procedure/SQL Query.
Saturday, March 24, 2012
Passing a "where" claus to populate a datagrid on another form.
It is my intention to open this form that contains a datagrid which returns the records that match their search criteria.
I have had success sending the information, but I am completely lost as to how I use this information.
I dragged the dbconnection, the dataadapter and created the dataset onto the form, but I am not sure if this is how I should have done it. Perhaps all of this should be done in code and create the select string in code for the dataadapter? Does anyone have code that they could share the accomplishes this?
Currently the form brings up all records, (before I started tinkering), but I do not know how to set the 'where' claus.
Thanks for your helpHere is some of the code I am working with:
Dim conn As New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=c:\Access_ResourceDB\Access_ResourceDb_Backend\ResourceDb_be.mdb")
Dim ds As New DataSet("MyDataSet")
Dim objCmd As New OleDbDataAdapter("Select RecId,Name,Age,Town,HowmPhone,Email FROM tblContacts " & "Where " & pasRecCrit & ";", conn)
conn.Open()
objCmd.Fill(ds, "MyDataSet")
Me.DataGrid1.DataSource = ds.Tables("MyDataSet")
Me.DataGrid1.DataBind()
This is just one of the ways I have tried. Right now I get an error stating that
"No value given for one or more required parameters", on the objCmd.fill line.
Thanks
What do have in the pasRecCrit variable? This looks like it should work. Maybe your Where clause isn't formatted correctly.
Wednesday, March 21, 2012
Passing a parameter to another page
The datagrid also contains a 'button column' which the user can use to edit and save changes to individual records to the db.
I use the following code to access the PK of the table in question as a parameter for my update query:
Dim strPatID As String = e.Item.Cells(0).Text
strSQL = "UPDATE blah "
strSQL = strSQL & "SET blah blah blah"
strSQL = strSQL & "WHERE patid = '" & strPatID & "'"
All of this works fine.
However, I also want users to be able to add records to a related table (which is at the many end of a relationship) based on the record they've selected from the datagrid. I've set up a 'hyperlink column' in the same datagrid which redirects them to another page where they'll be able to add data and save it. Fine so far.
The problem is of course, I need the patid as the foreign key to this second table. How can I pass this as a parameter to the second page? Am I doing this the right way or is there a better way to add records to related tables?
I hope I've made myself clear. Please let me know if you need additional information.
Thanks in advance for any help.
MoYou could pass it in the querystring to the new page:
DetailEntry.aspx?PatID=xxxxxx
On the second page, you can use Request.Querystring("PatID") to get the value
Thanks very much for the response Jim. I'll try it out.
Best regards to JimRoss:
In addition to using QueryString, you can also think of :
Session Variables as another solution, in addition to the other solutions.
regards
Passing a parameter to get results to post to a datagrid
here is my code:
<%@dotnet.itags.org. Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@dotnet.itags.org. Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<MM:DataSet
id="DataSetResults"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_CPAR") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_CPAR") %>'
CommandText='<%# "SELECT * FROM dbo.ListofNonconformities WHERE ""Reference Document"" = ?" %>'
Debug="true" PageSize="10"
><Parameters>
<Parameter Name="@dotnet.itags.org.Reference Document" Value='<%# IIf((Request.Form("FRefDoc") <> Nothing), Request.Form("FRefDoc"), "") %>' Type="WChar" /></Parameters></MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form action="" method="post" name="FRefDoc" id="FRefDoc" runat="server">
<p>
<% DDRefDoc.SelectedIndex = DDRefDoc.Items.IndexOf(DDRefDoc.Items.FindByValue(DataSetResults.FieldValue("Reference Document", Nothing) )) %><asp:DropDownList ID="DDRefDoc" runat="server" DataSource="<%# DataSetResults.DefaultView %>" DataTextField="Reference Document" DataValueField="Reference Document"></asp:DropDownList>
<asp:Button ID="BSubmit" runat="server" Text="Submit" /></p>
<p>
<asp:DataGrid id="DataGridResults"
runat="server"
AllowSorting="False"
AutoGenerateColumns="false"
CellPadding="3"
CellSpacing="0"
ShowFooter="false"
ShowHeader="true"
DataSource="<%# DataSetResults.DefaultView %>"
PagerStyle-Mode="NextPrev"
AllowPaging="true"
AllowCustomPaging="true"
PageSize="<%# DataSetResults.PageSize %>"
VirtualItemCount="<%# DataSetResults.RecordCount %>"
OnPageIndexChanged="DataSetResults.OnDataGridPageIndexChanged"
>
<HeaderStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />
<ItemStyle BackColor="#F2F2F2" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
<AlternatingItemStyle BackColor="#E5E5E5" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
<FooterStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />
<PagerStyle BackColor="white" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
<Columns>
<asp:BoundColumn DataField="ISO 9001 Clause"
HeaderText="ISO 9001 Clause"
ReadOnly="true"
Visible="True"/>
<asp:BoundColumn DataField="Expr1"
HeaderText="Expr1"
ReadOnly="true"
Visible="True"/>
<asp:BoundColumn DataField="Action To:"
HeaderText="Action To:"
ReadOnly="true"
Visible="True"/>
<asp:BoundColumn DataField="Description of Nonconformity"
HeaderText="Description of Nonconformity"
ReadOnly="true"
Visible="True"/>
<asp:BoundColumn DataField="Verified By"
HeaderText="Verified By"
ReadOnly="true"
Visible="True"/>
<asp:BoundColumn DataField="Submission Date"
HeaderText="Submission Date"
ReadOnly="true"
Visible="True"/>
<asp:BoundColumn DataField="Completion Date"
HeaderText="Completion Date"
ReadOnly="true"
Visible="True"/>
<asp:BoundColumn DataField="Verification Date"
HeaderText="Verification Date"
ReadOnly="true"
Visible="True"/>
<asp:BoundColumn DataField="Reference Document"
HeaderText="Reference Document"
ReadOnly="true"
Visible="True"/>
<asp:BoundColumn DataField="Process Owner"
HeaderText="Process Owner"
ReadOnly="true"
Visible="True"/>
<asp:BoundColumn DataField="Remarks"
HeaderText="Remarks"
ReadOnly="true"
Visible="True"/>
</Columns>
</asp:DataGrid>
</p>
<p> </p>
</form>
</body>
</html>that is very good
thank you
passing a string from the server to client side javascript
I have an ASP.NET website where one of my pages contain javascript that is a
check to see if anydata within a datagrid has changed. My problem is that it
takes a considerable amount of time to populate the array in the javascript
after the datagrid is populated.
What I am thinking of doing is creating a comma delimited string on the
server side (.vb) and then have the javascript pick it up through array()...
.
My problem that I am trying to figure out is how do I pass a string that is
created in a server side function back to the client so that a javascript
function could read it and populate an array.
Does anybody have any pointers how to do this?
Thank you,
LynersPrepare the commans separated string and then write it in JS block using
RegisterclientScriptBlock kind of methods. And then have another JS function
implementted that picks up this string and populate what ever you are
populating.
"Lyners" <Lyners@.discussions.microsoft.com> wrote in message
news:DF2717EF-9B7F-4CE7-B78E-973878F7092C@.microsoft.com...
> Hello all,
> I have an ASP.NET website where one of my pages contain javascript that is
> a
> check to see if anydata within a datagrid has changed. My problem is that
> it
> takes a considerable amount of time to populate the array in the
> javascript
> after the datagrid is populated.
> What I am thinking of doing is creating a comma delimited string on the
> server side (.vb) and then have the javascript pick it up through
> array()...
> My problem that I am trying to figure out is how do I pass a string that
> is
> created in a server side function back to the client so that a javascript
> function could read it and populate an array.
> Does anybody have any pointers how to do this?
> Thank you,
> Lyners
>
In your aspx file:
<%# MyString%>
In your VB-file:
Protected MyString as string = "m,y,s,t,r,i,n,g"
Hope this helps you
"Lyners" <Lyners@.discussions.microsoft.com> wrote in message
news:DF2717EF-9B7F-4CE7-B78E-973878F7092C@.microsoft.com...
> Hello all,
> I have an ASP.NET website where one of my pages contain javascript that is
> a
> check to see if anydata within a datagrid has changed. My problem is that
> it
> takes a considerable amount of time to populate the array in the
> javascript
> after the datagrid is populated.
> What I am thinking of doing is creating a comma delimited string on the
> server side (.vb) and then have the javascript pick it up through
> array()...
> My problem that I am trying to figure out is how do I pass a string that
> is
> created in a server side function back to the client so that a javascript
> function could read it and populate an array.
> Does anybody have any pointers how to do this?
> Thank you,
> Lyners
>
Thanks Maarten, but my string keeps coming back empty. I had a simular setup
prior to your comment, I changed the Public string to a protected string, bu
t
still no dice.
Here is my declaration and my statement that is creating the string:
Protected strIds As String = "Start"
In my loop I do the following;
dblRecordCounter = dblRecordCounter + 1
strIds = strIds & "," & "MyDataGrid__ctl" + Str(dblRecordCounter
+ 2) + "_txtField"
In the aspx file I have this;
ServerString = new String('<%# strIds%>');
var ids = ServerString.split(',');
but ids[0] or 1,2,3,4,5... is blank
I know I am missing something simple. Can you see it?
Thank you,
Lyner
"Maarten" wrote:
> In your aspx file:
> <%# MyString%>
> In your VB-file:
> Protected MyString as string = "m,y,s,t,r,i,n,g"
> Hope this helps you
> "Lyners" <Lyners@.discussions.microsoft.com> wrote in message
> news:DF2717EF-9B7F-4CE7-B78E-973878F7092C@.microsoft.com...
>
>
You are not sending the string to the client.
In your client html
function Page_onLoad() {
var blnVisible = <%= m_strVisible %>;
I knew it was something like this, but another question, because I still
don't have it working. Does the javascript fire off the Page_onLoad()
everytime the page is loaded? Because I put an alert in the onLoad part and
it never fired, which leads me to think that in the body tag I need to put a
n
onLoad event to pick up the string.
Correct or not?
Thans alot!
"sirfunusa" wrote:
> You are not sending the string to the client.
> In your client html
> function Page_onLoad() {
> var blnVisible = <%= m_strVisible %>;
>
This is normally done with a hidden input control:
<input type=hidden runat=server id=inhMyParameter">
Eliyahu
"Lyners" <Lyners@.discussions.microsoft.com> wrote in message
news:DF2717EF-9B7F-4CE7-B78E-973878F7092C@.microsoft.com...
> Hello all,
> I have an ASP.NET website where one of my pages contain javascript that is
> a
> check to see if anydata within a datagrid has changed. My problem is that
> it
> takes a considerable amount of time to populate the array in the
> javascript
> after the datagrid is populated.
> What I am thinking of doing is creating a comma delimited string on the
> server side (.vb) and then have the javascript pick it up through
> array()...
> My problem that I am trying to figure out is how do I pass a string that
> is
> created in a server side function back to the client so that a javascript
> function could read it and populate an array.
> Does anybody have any pointers how to do this?
> Thank you,
> Lyners
>
Incorrect. Perhaps you posted to the wrong question? He was asking how
to pass a string from server to client.
Why do you think is it incorrect?
Eliyahu
"sirfunusa" <sirfunusa@.hotmail.com> wrote in message
news:1144081480.686619.283100@.i39g2000cwa.googlegroups.com...
> Incorrect. Perhaps you posted to the wrong question? He was asking how
> to pass a string from server to client.
>
Not incorrect at all. Use of hidden field is another approach to do the same
thing.
"sirfunusa" <sirfunusa@.hotmail.com> wrote in message
news:1144081480.686619.283100@.i39g2000cwa.googlegroups.com...
> Incorrect. Perhaps you posted to the wrong question? He was asking how
> to pass a string from server to client.
>
passing a string from the server to client side javascript
I have an ASP.NET website where one of my pages contain javascript that is a
check to see if anydata within a datagrid has changed. My problem is that it
takes a considerable amount of time to populate the array in the javascript
after the datagrid is populated.
What I am thinking of doing is creating a comma delimited string on the
server side (.vb) and then have the javascript pick it up through array()...
My problem that I am trying to figure out is how do I pass a string that is
created in a server side function back to the client so that a javascript
function could read it and populate an array.
Does anybody have any pointers how to do this?
Thank you,
LynersPrepare the commans separated string and then write it in JS block using
RegisterclientScriptBlock kind of methods. And then have another JS function
implementted that picks up this string and populate what ever you are
populating.
"Lyners" <Lyners@.discussions.microsoft.com> wrote in message
news:DF2717EF-9B7F-4CE7-B78E-973878F7092C@.microsoft.com...
> Hello all,
> I have an ASP.NET website where one of my pages contain javascript that is
> a
> check to see if anydata within a datagrid has changed. My problem is that
> it
> takes a considerable amount of time to populate the array in the
> javascript
> after the datagrid is populated.
> What I am thinking of doing is creating a comma delimited string on the
> server side (.vb) and then have the javascript pick it up through
> array()...
> My problem that I am trying to figure out is how do I pass a string that
> is
> created in a server side function back to the client so that a javascript
> function could read it and populate an array.
> Does anybody have any pointers how to do this?
> Thank you,
> Lyners
In your aspx file:
<%# MyString%
In your VB-file:
Protected MyString as string = "m,y,s,t,r,i,n,g"
Hope this helps you
"Lyners" <Lyners@.discussions.microsoft.com> wrote in message
news:DF2717EF-9B7F-4CE7-B78E-973878F7092C@.microsoft.com...
> Hello all,
> I have an ASP.NET website where one of my pages contain javascript that is
> a
> check to see if anydata within a datagrid has changed. My problem is that
> it
> takes a considerable amount of time to populate the array in the
> javascript
> after the datagrid is populated.
> What I am thinking of doing is creating a comma delimited string on the
> server side (.vb) and then have the javascript pick it up through
> array()...
> My problem that I am trying to figure out is how do I pass a string that
> is
> created in a server side function back to the client so that a javascript
> function could read it and populate an array.
> Does anybody have any pointers how to do this?
> Thank you,
> Lyners
Thanks Maarten, but my string keeps coming back empty. I had a simular setup
prior to your comment, I changed the Public string to a protected string, but
still no dice.
Here is my declaration and my statement that is creating the string:
Protected strIds As String = "Start"
In my loop I do the following;
dblRecordCounter = dblRecordCounter + 1
strIds = strIds & "," & "MyDataGrid__ctl" + Str(dblRecordCounter
+ 2) + "_txtField"
In the aspx file I have this;
ServerString = new String('<%# strIds%>');
var ids = ServerString.split(',');
but ids[0] or 1,2,3,4,5... is blank
I know I am missing something simple. Can you see it?
Thank you,
Lyner
"Maarten" wrote:
> In your aspx file:
> <%# MyString%>
> In your VB-file:
> Protected MyString as string = "m,y,s,t,r,i,n,g"
> Hope this helps you
> "Lyners" <Lyners@.discussions.microsoft.com> wrote in message
> news:DF2717EF-9B7F-4CE7-B78E-973878F7092C@.microsoft.com...
> > Hello all,
> > I have an ASP.NET website where one of my pages contain javascript that is
> > a
> > check to see if anydata within a datagrid has changed. My problem is that
> > it
> > takes a considerable amount of time to populate the array in the
> > javascript
> > after the datagrid is populated.
> > What I am thinking of doing is creating a comma delimited string on the
> > server side (.vb) and then have the javascript pick it up through
> > array()...
> > My problem that I am trying to figure out is how do I pass a string that
> > is
> > created in a server side function back to the client so that a javascript
> > function could read it and populate an array.
> > Does anybody have any pointers how to do this?
> > Thank you,
> > Lyners
>
You are not sending the string to the client.
In your client html
function Page_onLoad() {
var blnVisible = <%= m_strVisible %>;
I knew it was something like this, but another question, because I still
don't have it working. Does the javascript fire off the Page_onLoad()
everytime the page is loaded? Because I put an alert in the onLoad part and
it never fired, which leads me to think that in the body tag I need to put an
onLoad event to pick up the string.
Correct or not?
Thans alot!
"sirfunusa" wrote:
> You are not sending the string to the client.
> In your client html
> function Page_onLoad() {
> var blnVisible = <%= m_strVisible %>;
>
This is normally done with a hidden input control:
<input type=hidden runat=server id=inhMyParameter"
Eliyahu
"Lyners" <Lyners@.discussions.microsoft.com> wrote in message
news:DF2717EF-9B7F-4CE7-B78E-973878F7092C@.microsoft.com...
> Hello all,
> I have an ASP.NET website where one of my pages contain javascript that is
> a
> check to see if anydata within a datagrid has changed. My problem is that
> it
> takes a considerable amount of time to populate the array in the
> javascript
> after the datagrid is populated.
> What I am thinking of doing is creating a comma delimited string on the
> server side (.vb) and then have the javascript pick it up through
> array()...
> My problem that I am trying to figure out is how do I pass a string that
> is
> created in a server side function back to the client so that a javascript
> function could read it and populate an array.
> Does anybody have any pointers how to do this?
> Thank you,
> Lyners
Incorrect. Perhaps you posted to the wrong question? He was asking how
to pass a string from server to client.
Why do you think is it incorrect?
Eliyahu
"sirfunusa" <sirfunusa@.hotmail.com> wrote in message
news:1144081480.686619.283100@.i39g2000cwa.googlegr oups.com...
> Incorrect. Perhaps you posted to the wrong question? He was asking how
> to pass a string from server to client.
Not incorrect at all. Use of hidden field is another approach to do the same
thing.
"sirfunusa" <sirfunusa@.hotmail.com> wrote in message
news:1144081480.686619.283100@.i39g2000cwa.googlegr oups.com...
> Incorrect. Perhaps you posted to the wrong question? He was asking how
> to pass a string from server to client.
You never set the value.
Friday, March 16, 2012
Passing a variable into a event handler.
I have a datagrid in a repeater, and i populate it with a dataTable, which is retrieved with a StationId that completes the SQL query. Now, when i try to page the dgrd i have to pass that stationId into the paging function.
Since the paging funtion is an eventHandler, it has (object sender, DataGridPageChangedEventArgs e) and so i can't pass any other variables into it
any ideas?Hi,
the DataGridPagechangedEventArgs an be used to get the id of the daatgrid,
can u please check this !!!
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIWebControlsDataGridPageChangedEventArgsClassTopic.asp
in that article u an find code which u can use and make use of to understand your situation !!
passing a variable to frame from a datagrid...
what i want to do is when i click on an item on a datagrid,the selected item would be sent to other frame.
I use javascript to send data to other frame. But problem is when i select item, first javascript called and then method called. Do you know how to call method first and then javascript function..or do you have any idea to do same thing?
Thank you very much!are you dnamically loading a new page in the frame?
if so, pass parameters in the url like "page.aspx?param=value"
then in the page, look at the Request.Params property to get the values.
or set a session variable in the main page, and read it out in the frame page
No, the page in the frame is not dynamically loading.
Do you know how to refresh a page in a frame from other frame?
thanks