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?
pass parameter in hyperlink
I am displaying the results of a query in a datalist. There are 2 fields returned with one an icon set as a hyperlink as follows:
name
When someone clicks on the icon I would like the name parameter to be passed to a new page to be used in a new query. Can someone please point me in the right direction.
Matt
The simplest way of doing this is to append the name as a query string variable, e.g.
<a href="http://links.10026.com/?link=http://someurl.com?name=xyz">...</a>
Thanks for the quick response. My code looks as follows:
<ItemTemplate>
<asp:HyperLink ID="Hyperlink1" runat="server" NavigateUrl="~/Login.aspx"><asp:Image ID="Image1" runat="server" ImageUrl='<%# SetUrl(Eval("status")) %>' ImageAlign="Middle" /></asp:HyperLink><br />
<asp:Label ID="term_idLabel" runat="server" Text='<%# Eval("term_id") %>' Font-Names="Arial" Font-Size="Small" ForeColor="White"></asp:Label><br />
<br />
</ItemTemplate
Which displays my data as:
name1 name2
If the user clicks on name1's icon I'd like to pass name1 as the parameter. How do I access this term_idLabel instance?
You'll want to change the NavigateUrl property in HyperLink1 so the term_id is evaluated and passed as a parameter. Try this:
NavigateUrl='<%# Eval("term_id", "~/Login.aspx?name={0}") %>' The string will be formatted with the value for term_id replacing the {0}.
Pass Parameter To MasterPage ?
I'd like to pass SectionID from the ChildPages to the MasterPage
(which calculates information based on SectionID)A good way is to declare a public property SectionID on the master page and
set it from content pages as this.Master.SectionID=xxx
You will need to add a line
<%@. MasterType virtualpath="~/MyMaster.master" %>
into your content page.
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
<googlegroup@.desiboy.com> wrote in message
news:1168928761.038462.121050@.38g2000cwa.googlegroups.com...
> How do you pass a parameter into the master pages, much like the TITLE.
> I'd like to pass SectionID from the ChildPages to the MasterPage
> (which calculates information based on SectionID)
>
Pass Parameter To MasterPage ?
I'd like to pass SectionID from the ChildPages to the MasterPage
(which calculates information based on SectionID)A good way is to declare a public property SectionID on the master page and
set it from content pages as this.Master.SectionID=xxx
You will need to add a line
<%@. MasterType virtualpath="~/MyMaster.master" %>
into your content page.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
<googlegroup@.desiboy.comwrote in message
news:1168928761.038462.121050@.38g2000cwa.googlegro ups.com...
Quote:
Originally Posted by
How do you pass a parameter into the master pages, much like the TITLE.
I'd like to pass SectionID from the ChildPages to the MasterPage
(which calculates information based on SectionID)
>
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 Parameter to DataList Datasource!
I am trying pass a value to the DataSource method in a DataList like below.
DataSource = <%# GetData(DataBinder.Eval(Container.DataItem, "ID"))%>"
I get an error with this code, and am wondering if someone can show me the
correct syntax.
I have asked this question before, but unfortunately i don't remember the
correct syntax.
I know i can acheive the desired result using code behind 'ItemDataBound',
but am prefering to do it in the aspx page itself..
All help appreciated.
<asp:DataList ID="dlTest"
DataKeyField = "ID"
DataSource = <%# GetData(DataBinder.Eval(Container.DataItem,
"ID"))%>">
<ItemTemplate><%# DataBinder.Eval(Container.DataItem,
"Name")%></ItemTemplate>
</asp:DataList>
Cheers,
AdamDataSource should be set to an on object containing data items. What is it
in your case?
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"AJ" <AJ@.discussions.microsoft.comwrote in message
news:3C74BA0B-76DB-42B0-A32B-E2EF219A44BC@.microsoft.com...
Quote:
Originally Posted by
Hi all,
>
I am trying pass a value to the DataSource method in a DataList like
below.
DataSource = <%# GetData(DataBinder.Eval(Container.DataItem, "ID"))%>"
>
I get an error with this code, and am wondering if someone can show me the
correct syntax.
>
I have asked this question before, but unfortunately i don't remember the
correct syntax.
>
I know i can acheive the desired result using code behind 'ItemDataBound',
but am prefering to do it in the aspx page itself..
>
All help appreciated.
>
<asp:DataList ID="dlTest"
DataKeyField = "ID"
DataSource = <%# GetData(DataBinder.Eval(Container.DataItem,
"ID"))%>">
<ItemTemplate><%# DataBinder.Eval(Container.DataItem,
"Name")%></ItemTemplate>
</asp:DataList>
>
Cheers,
Adam
Pass parameter to Popup window
On Webform1, I have one text box1 and one button.
on Webform2, I have one text box .
I need transfer the value of textbox 1 in webform1 to textbox2 in
webform2. and popup webform2 when user click on the button on webform1.
I have code in webform1:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Button1.Attributes.Add("onclick", "window.open('WebForm2.aspx?a=" +
TextBox1.Text.ToString + "',null,'height=250, width=250,status= no,
resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no ');")
End Sub
and following code in webform2:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
TextBox1.Text = Request("a").ToString
End Sub
I could not get the result unless I click on the button1 twice. i know
what happen in here but have no solution. I will be appreciated if you
could help here.
Thanks in advanced,
DiHi ,
You can achieve this by injecting a javascript in the Button1 click
event on the server side . Write an function to inject an javascript in the
webform1 button1 click.
Don't do anything with Attributes of button1 as it won't achieve result u
requires as the 1st page the textbox1 value would be blank.
private void openWindowInjectScript(){
string myScript;
myScript = "<scr" + "ipt>window.open('WebForm2.aspx?a=" + txtIdfield.Value
+ "',null,'height=250, width=250,status= no,resizable= no, scrollbars=no,
toolbar=no,location=no,menubar=no'); </scr" + "ipt>";
this.Page.RegisterStartupScript("JavaScript",myScript);
}
In the webform1.aspx button1_Click event
private void Button1_Click(object sender, System.EventArgs e)
{
openWindowInjectScript();
}
Basically openwindowInjectScript register a script at pageload and which
will make to open an window with current values.
This is the way out for it and it should work
Regards
IntelYogi
"dyw55a@.yahoo.com" wrote:
> I have 2 webform in vb.NET application.
> On Webform1, I have one text box1 and one button.
> on Webform2, I have one text box .
> I need transfer the value of textbox 1 in webform1 to textbox2 in
> webform2. and popup webform2 when user click on the button on webform1.
> I have code in webform1:
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Button1.Attributes.Add("onclick", "window.open('WebForm2.aspx?a=" +
> TextBox1.Text.ToString + "',null,'height=250, width=250,status= no,
> resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no ');")
> End Sub
> and following code in webform2:
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> TextBox1.Text = Request("a").ToString
> End Sub
>
> I could not get the result unless I click on the button1 twice. i know
> what happen in here but have no solution. I will be appreciated if you
> could help here.
> Thanks in advanced,
> Di
>
Thank you for your reply. But actually I tried and this did not work
for some reason, any idea?
Try this onClick event of your button
Response.Write("<SCRIPT>");
Response.Write("window.open('page,aspx?value=" + myval +
" ',null,'height=200,width=900,status=yes,
toolbar=no,menubar=no,location=no')
;
");
Response.Write("</SCRIPT>");
I think this will do the trick, tell me if not
dyw55a@.yahoo.com wrote in message news:<1117647067.875660.133640@.g43g2000cwa.googlegroups.c
om>...
> Thank you for your reply. But actually I tried and this did not work
> for some reason, any idea?
Pass parameter to Popup window
On Webform1, I have one text box1 and one button.
on Webform2, I have one text box .
I need transfer the value of textbox 1 in webform1 to textbox2 in
webform2. and popup webform2 when user click on the button on webform1.
I have code in webform1:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Button1.Attributes.Add("onclick", "window.open('WebForm2.aspx?a=" +
TextBox1.Text.ToString + "',null,'height=250, width=250,status= no,
resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no ');")
End Sub
and following code in webform2:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
TextBox1.Text = Request("a").ToString
End Sub
I could not get the result unless I click on the button1 twice. i know
what happen in here but have no solution. I will be appreciated if you
could help here.
Thanks in advanced,
DiHi ,
You can achieve this by injecting a javascript in the Button1 click
event on the server side . Write an function to inject an javascript in the
webform1 button1 click.
Don't do anything with Attributes of button1 as it won't achieve result u
requires as the 1st page the textbox1 value would be blank.
private void openWindowInjectScript(){
string myScript;
myScript = "<scr" + "ipt>window.open('WebForm2.aspx?a=" + txtIdfield.Value
+ "',null,'height=250, width=250,status= no,resizable= no, scrollbars=no,
toolbar=no,location=no,menubar=no'); </scr" + "ipt>";
this.Page.RegisterStartupScript("JavaScript",myScript);
}
In the webform1.aspx button1_Click event
private void Button1_Click(object sender, System.EventArgs e)
{
openWindowInjectScript();
}
Basically openwindowInjectScript register a script at pageload and which
will make to open an window with current values.
This is the way out for it and it should work
Regards
IntelYogi
"dyw55a@.yahoo.com" wrote:
> I have 2 webform in vb.NET application.
> On Webform1, I have one text box1 and one button.
> on Webform2, I have one text box .
> I need transfer the value of textbox 1 in webform1 to textbox2 in
> webform2. and popup webform2 when user click on the button on webform1.
> I have code in webform1:
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Button1.Attributes.Add("onclick", "window.open('WebForm2.aspx?a=" +
> TextBox1.Text.ToString + "',null,'height=250, width=250,status= no,
> resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no ');")
> End Sub
> and following code in webform2:
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> TextBox1.Text = Request("a").ToString
> End Sub
>
> I could not get the result unless I click on the button1 twice. i know
> what happen in here but have no solution. I will be appreciated if you
> could help here.
> Thanks in advanced,
> Di
>
Thank you for your reply. But actually I tried and this did not work
for some reason, any idea?
Try this onClick event of your button
Response.Write("<SCRIPT>");
Response.Write("window.open('page,aspx?value=" + myval +
"',null,'height=200,width=900,status=yes,toolbar=no ,menubar=no,location=no');
");
Response.Write("</SCRIPT>");
I think this will do the trick, tell me if not
dyw55a@.yahoo.com wrote in message news:<1117647067.875660.133640@.g43g2000cwa.googlegroups. com>...
> Thank you for your reply. But actually I tried and this did not work
> for some reason, any idea?
i'd tried both suggest solutions from Yogi, but it seems not work for me...is any solution yet?
the prob is...webform2's page_load will be run 1st b4 the button_click event run...so any wisdom can help up?
From http://www.developmentnow.com/g/8_2...opup-window.htm
Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Pass parameters to User Control
I am using a User Control which is referenced by an ASPX page.
How can I pass a string parameter to the user control, from the base ASPX
page.
Thanks
BenHi Ben,
Create a public method in the usercontrol and access the same from the aspx
page.
Ex:
Code in myusercontrol.ascx.cs
public void PublicMethodInUsercontrol(string valuetopasstocontrol)
{
privatevariable = valuetopasstocontrol;
}
Code in the aspx page.
usercontrolinstance.PublicMethodInUsercontrol("MyValueFromPage");
HTH
Regards
Ashish M Bhonkiya
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
For this purpose I used to create properties (in user control). This way you
can also pass parameters from aspx file (html).
You can access Session to retrieve values. There're plenty of ways. In case
you need some code, I'll try to post.
--
With the best wishes,
Shaul Feldman
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
Sorry for the delay in replying:
I have heard that you can use this method to pass the parameter:
<%@.Register tagprefix="CodeLib" Tagname="usrMain" src="http://pics.10026.com/?src=usrMain.ascx" %
<CodeLib:usrMain bodyData="usrText.ascx" linksPage="NoLinks"
requireSecure="False" runat="server" ID="usrMain"/
But the problem is that I cannot seem to extract the data on the ASCX page
Thanks Ben
"Shaul Feldman" <sfeldman@.writeme.com> wrote in message
news:e$%23BiHkJEHA.3944@.tk2msftngp13.phx.gbl...
> For this purpose I used to create properties (in user control). This way
you
> can also pass parameters from aspx file (html).
> You can access Session to retrieve values. There're plenty of ways. In
case
> you need some code, I'll try to post.
> --
> With the best wishes,
> Shaul Feldman
> "Ben" <Ben@.nospam.com> wrote in message
> news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> > Hi
> > I am using a User Control which is referenced by an ASPX page.
> > How can I pass a string parameter to the user control, from the base
ASPX
> > page.
> > Thanks
> > Ben
Help! I have an aspx that loads the ascx with parameters in a
placeholder as textboxes. On my postback I can't get the values out
of the textboxes. They are still on the screen so I'm sure they are
there.
I'm having a hard time. I've been told they should just be there.
aspx
ascx
ascxwp
The ascxwp is the user control that holds the textboxes.
I assume someone has figured this out. We have 3 asp programmers and
we are all stumped.
"Shaul Feldman" <sfeldman@.writeme.com> wrote in message news:<e$#BiHkJEHA.3944@.tk2msftngp13.phx.gbl>...
> For this purpose I used to create properties (in user control). This way you
> can also pass parameters from aspx file (html).
> You can access Session to retrieve values. There're plenty of ways. In case
> you need some code, I'll try to post.
> --
> With the best wishes,
> Shaul Feldman
> "Ben" <Ben@.nospam.com> wrote in message
> news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> > Hi
> > I am using a User Control which is referenced by an ASPX page.
> > How can I pass a string parameter to the user control, from the base ASPX
> > page.
> > Thanks
> > Ben
Implement Properties inside of your UserControl
e.g.
Public Property FirstName() as String
Get
Return txtFirstName.text
End Get
Set (value as String)
txtFirstName.text=value
end set
end property
Then just access the properties
"Lynne K." <ltgaer@.assurity.com> wrote in message
news:7a65e5b4.0405110605.559f0d2d@.posting.google.c om...
> Help! I have an aspx that loads the ascx with parameters in a
> placeholder as textboxes. On my postback I can't get the values out
> of the textboxes. They are still on the screen so I'm sure they are
> there.
> I'm having a hard time. I've been told they should just be there.
> aspx
> ascx
> ascxwp
> The ascxwp is the user control that holds the textboxes.
> I assume someone has figured this out. We have 3 asp programmers and
> we are all stumped.
> "Shaul Feldman" <sfeldman@.writeme.com> wrote in message
news:<e$#BiHkJEHA.3944@.tk2msftngp13.phx.gbl>...
> > For this purpose I used to create properties (in user control). This way
you
> > can also pass parameters from aspx file (html).
> > You can access Session to retrieve values. There're plenty of ways. In
case
> > you need some code, I'll try to post.
> > --
> > With the best wishes,
> > Shaul Feldman
> > "Ben" <Ben@.nospam.com> wrote in message
> > news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> > > Hi
> > > > I am using a User Control which is referenced by an ASPX page.
> > > > How can I pass a string parameter to the user control, from the base
ASPX
> > > page.
> > > > Thanks
> > > > Ben
> >
Pass parameters to User Control
I am using a User Control which is referenced by an ASPX page.
How can I pass a string parameter to the user control, from the base ASPX
page.
Thanks
BenHi Ben,
Create a public method in the usercontrol and access the same from the aspx
page.
Ex:
Code in myusercontrol.ascx.cs
public void PublicMethodInUsercontrol(string valuetopasstocontrol)
{
privatevariable = valuetopasstocontrol;
}
Code in the aspx page.
usercontrolinstance.PublicMethodInUsercontrol("MyValueFromPage");
HTH
Regards
Ashish M Bhonkiya
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
>
For this purpose I used to create properties (in user control). This way you
can also pass parameters from aspx file (html).
You can access Session to retrieve values. There're plenty of ways. In case
you need some code, I'll try to post.
With the best wishes,
Shaul Feldman
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
>
Sorry for the delay in replying:
I have heard that you can use this method to pass the parameter:
<%@.Register tagprefix="CodeLib" Tagname="usrMain" src="http://pics.10026.com/?src=usrMain.ascx" %>
<CodeLib:usrMain bodyData="usrText.ascx" linksPage="NoLinks"
requireSecure="False" runat="server" ID="usrMain"/>
But the problem is that I cannot seem to extract the data on the ASCX page
Thanks Ben
"Shaul Feldman" <sfeldman@.writeme.com> wrote in message
news:e$%23BiHkJEHA.3944@.tk2msftngp13.phx.gbl...
> For this purpose I used to create properties (in user control). This way
you
> can also pass parameters from aspx file (html).
> You can access Session to retrieve values. There're plenty of ways. In
case
> you need some code, I'll try to post.
> --
> With the best wishes,
> Shaul Feldman
> "Ben" <Ben@.nospam.com> wrote in message
> news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
ASPX
>
Implement Properties inside of your UserControl
e.g.
Public Property FirstName() as String
Get
Return txtFirstName.text
End Get
Set (value as String)
txtFirstName.text=value
end set
end property
Then just access the properties
"Lynne K." <ltgaer@.assurity.com> wrote in message
news:7a65e5b4.0405110605.559f0d2d@.posting.google.com...
> Help! I have an aspx that loads the ascx with parameters in a
> placeholder as textboxes. On my postback I can't get the values out
> of the textboxes. They are still on the screen so I'm sure they are
> there.
> I'm having a hard time. I've been told they should just be there.
> aspx
> ascx
> ascxwp
> The ascxwp is the user control that holds the textboxes.
> I assume someone has figured this out. We have 3 asp programmers and
> we are all stumped.
> "Shaul Feldman" <sfeldman@.writeme.com> wrote in message
news:<e$#BiHkJEHA.3944@.tk2msftngp13.phx.gbl>...
you
case
ASPX
Pass parameters to User Control
I am using a User Control which is referenced by an ASPX page.
How can I pass a string parameter to the user control, from the base ASPX
page.
Thanks
BenHi Ben,
Create a public method in the usercontrol and access the same from the aspx
page.
Ex:
Code in myusercontrol.ascx.cs
public void PublicMethodInUsercontrol(string valuetopasstocontrol)
{
privatevariable = valuetopasstocontrol;
}
Code in the aspx page.
usercontrolinstance.PublicMethodInUsercontrol("MyValueFromPage");
HTH
Regards
Ashish M Bhonkiya
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
For this purpose I used to create properties (in user control). This way you
can also pass parameters from aspx file (html).
You can access Session to retrieve values. There're plenty of ways. In case
you need some code, I'll try to post.
--
With the best wishes,
Shaul Feldman
"Ben" <Ben@.nospam.com> wrote in message
news:u4tZ4ShJEHA.1764@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using a User Control which is referenced by an ASPX page.
> How can I pass a string parameter to the user control, from the base ASPX
> page.
> Thanks
> Ben
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 values
"tcktreceived" in my database and I want to pass all the rows one by
one to the parameter @dotnet.itags.org.starttime. I don't know how to do it.
CREATE PROCEDURE [twcsan].[usp_DateDiff]
-- Add the parameters for the stored procedure here
@dotnet.itags.org.starttime DateTime
AS
BEGIN
DECLARE @dotnet.itags.org.Diff Varchar(15)
DECLARE @dotnet.itags.org.Day INT
DECLARE @dotnet.itags.org.Hour INT
DECLARE @dotnet.itags.org.Minute INT
DECLARE @dotnet.itags.org.Start_Date DateTime
DECLARE @dotnet.itags.org.End_Date DateTime
DECLARE @dotnet.itags.org.itemReceived DateTime
DECLARE @dotnet.itags.org.ID INT
DECLARE @dotnet.itags.org.message VARCHAR(50)
DECLARE @dotnet.itags.org.table TABLE
(
ItemReceived DateTime,
ID INT,
message text,
Differnce VARCHAR(20)
)
SET NOCOUNT ON;
SET @dotnet.itags.org.Start_Date = @dotnet.itags.org.starttime
SET @dotnet.itags.org.End_Date = GETDATE()
SET @dotnet.itags.org.Day = DATEDIFF( day, @dotnet.itags.org.Start_Date, @dotnet.itags.org.End_Date)
SET @dotnet.itags.org.Hour = DATEDIFF(hour , @dotnet.itags.org.Start_Date, @dotnet.itags.org.End_Date)
SET @dotnet.itags.org.Minute = DATEDIFF(minute , @dotnet.itags.org.Start_Date, @dotnet.itags.org.End_Date)
SET @dotnet.itags.org.Minute = @dotnet.itags.org.Minute-(@dotnet.itags.org.HOUR* 60)
SET @dotnet.itags.org.Hour = @dotnet.itags.org.Hour-(24* @dotnet.itags.org.Day)
SET @dotnet.itags.org.Diff = CONVERT(Varchar, @dotnet.itags.org.Day) +'d ' + CONVERT(Varchar , @dotnet.itags.org.Hour) +
'h ' + CONVERT(Varchar , @dotnet.itags.org.Minute) +'m'
INSERT INTO @dotnet.itags.org.table(ItemReceived, ID, message, Differnce)
select tck.tcktreceived, tck.ticketid,tckmsg.tcktmessage,@dotnet.itags.org.Diff
from tbtickets tck inner join tbticketsmessages tckmsg
on tck.ticketid = tckmsg.ticketid
select * from @dotnet.itags.org.table
ENDI'm not sure what your after, but try looking at using "Cursor" that might
give you what you need.
Pass values
"tcktreceived" in my database and I want to pass all the rows one by
one to the parameter @dotnet.itags.org.starttime. I don't know how to do it.
CREATE PROCEDURE [twcsan].[usp_DateDiff]
-- Add the parameters for the stored procedure here
@dotnet.itags.org.starttime DateTime
AS
BEGIN
DECLARE @dotnet.itags.org.Diff Varchar(15)
DECLARE @dotnet.itags.org.Day INT
DECLARE @dotnet.itags.org.Hour INT
DECLARE @dotnet.itags.org.Minute INT
DECLARE @dotnet.itags.org.Start_Date DateTime
DECLARE @dotnet.itags.org.End_Date DateTime
DECLARE @dotnet.itags.org.itemReceived DateTime
DECLARE @dotnet.itags.org.ID INT
DECLARE @dotnet.itags.org.message VARCHAR(50)
DECLARE @dotnet.itags.org.table TABLE
(
ItemReceived DateTime,
ID INT,
message text,
Differnce VARCHAR(20)
)
SET NOCOUNT ON;
SET @dotnet.itags.org.Start_Date = @dotnet.itags.org.starttime
SET @dotnet.itags.org.End_Date = GETDATE()
SET @dotnet.itags.org.Day = DATEDIFF( day, @dotnet.itags.org.Start_Date, @dotnet.itags.org.End_Date)
SET @dotnet.itags.org.Hour = DATEDIFF(hour , @dotnet.itags.org.Start_Date, @dotnet.itags.org.End_Date)
SET @dotnet.itags.org.Minute = DATEDIFF(minute , @dotnet.itags.org.Start_Date, @dotnet.itags.org.End_Date)
SET @dotnet.itags.org.Minute = @dotnet.itags.org.Minute-(@dotnet.itags.org.HOUR* 60)
SET @dotnet.itags.org.Hour = @dotnet.itags.org.Hour-(24* @dotnet.itags.org.Day)
SET @dotnet.itags.org.Diff = CONVERT(Varchar, @dotnet.itags.org.Day) +'d ' + CONVERT(Varchar , @dotnet.itags.org.Hour) +
'h ' + CONVERT(Varchar , @dotnet.itags.org.Minute) +'m'
INSERT INTO @dotnet.itags.org.table(ItemReceived, ID, message, Differnce)
select tck.tcktreceived, tck.ticketid,tckmsg.tcktmessage,@dotnet.itags.org.Diff
from tbtickets tck inner join tbticketsmessages tckmsg
on tck.ticketid = tckmsg.ticketid
select * from @dotnet.itags.org.table
ENDI'm not sure what your after, but try looking at using "Cursor" that might
give you what you need.
Saturday, March 24, 2012
Passing 2 Parameters from Datalist Control?
I have master/detail pages and pass a parameter from master page (datalist control) to detail page using session method.
Session.Add(
"prm_type", DataList1.SelectedValue);Response.Redirect("detail.aspx");
The code, I had placed in the datalist "selectedindexchanged" method, above works well. In addition to this, I placed a textbox control in the datalist control to pass a second parameter to detail page. But i don't know how to reach that textbox value and pass the parameter to detail page within datalist selectedindexchanged method like above. I tried something like below, but i couldn't figure out.
Session.Add("prm_quantity", ? this must be my textbox control value);
How can i pass a second parameter like this?
Try with this:
TextBox tbText = (TextBox)DataList1.FindControl("TextBox1");
Session.Add("prm_quantity", tbText.Text);
I got an error message on this line:
Session.Add(
"prm_quantity", tbText.Text);"NullReferenceException was unhandled by user code"
"Object reference not set to an instance of an object"
Hi,
It may be cache issue. Please look at this KB:
http://www.kbalertz.com/Feedback_831382.aspx
Good luck!
Wednesday, March 21, 2012
Passing a parameter through the URL
Then an email is sent to the admin who then goes to an asp.net page and activates the user if he chooses to.
My question is how can I pass the UserID in that email link so that when the admin goes to the generic 'Activate User' page the info for the user at that UserID is brought up?
Basically I want to pass the UID in the email URL link and then grab it when that page is hit later.Registerthem.aspx?UID=blahblahbla
then on Registerthem.aspx:
string UserID=Request("UID");
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 pop up window by javascript how?
in
window.open("WebForm26.aspx?User=txtUser.Text",................)If you use ASP.NET, you can move the entire Javascript to the server side by
using
Page.RegisterStartupScript, and then all server-side variables are available
to be passed to Javascript.
Ryan
"Bishoy George" wrote:
> how to let javascript code understand txtUser.Text?
> in
> window.open("WebForm26.aspx?User=txtUser.Text",................)
>
>
Xref: TK2MSFTNGP08.phx.gbl microsoft.public.dotnet.framework.aspnet:348893
On Mon, 26 Sep 2005 22:16:25 +0300, Bishoy George wrote:
> how to let javascript code understand txtUser.Text?
> in
> window.open("WebForm26.aspx?User=txtUser.Text",................)
Use
window.open("WebForm26.aspx?User=<%=txtUser.Text%>",....
Could you give me an example please?
still I can't send a parameter through javascript
window.open("url.aspx...- = --"); // VERY IMPORTANT to me
Also:
Can I write my C# code in the code behind page and just calling a javascript
method by this way?
"Call Javascrip from the server side" <Call Javascrip from the server
side@.discussions.microsoft.com> wrote in message
news:DF3EADAE-E4A8-49C0-AEA0-B58D2D6D2FA4@.microsoft.com...
> If you use ASP.NET, you can move the entire Javascript to the server side
> by
> using
> Page.RegisterStartupScript, and then all server-side variables are
> available
> to be passed to Javascript.
> Ryan
> "Bishoy George" wrote:
>
On Mon, 26 Sep 2005 23:46:52 +0300, Bishoy George wrote:
> Could you give me an example please?
> still I can't send a parameter through javascript
> window.open("url.aspx...- = --"); // VERY IMPORTANT to me
> Also:
> Can I write my C# code in the code behind page and just calling a javascri
pt
> method by this way?
> "Call Javascrip from the server side" <Call Javascrip from the server
> side@.discussions.microsoft.com> wrote in message
> news:DF3EADAE-E4A8-49C0-AEA0-B58D2D6D2FA4@.microsoft.com...
The Page.RegisterStartupScript points to a code behind way to do it. The
other way is using inline <%= txtUser.Text %> which is very convenient and
direct.
still doesn't work!!!
---this is my aspx
page ----
<%@. Page language="c#" Codebehind="WebForm25.aspx.cs"
AutoEventWireup="false" Inherits="WebApplication1.WebForm25" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm25</title>
<script language="javascript">
function PopUp()
{
window.open("WebForm26.aspx?User=<%=txtUser.Text%>","popupWin","toolbar=0,
location=0, status=0, menubar=0, scrollbar=0, resizable=0, width=600,
height=400, left=50, top=50",true);
}
</script>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Label id="lblUser" style="Z-INDEX: 101; LEFT: 24px; POSITION:
absolute; TOP: 48px" runat="server"
Width="80px" Height="22px">User Name:</asp:Label>
<asp:TextBox id="txtUser" style="Z-INDEX: 102; LEFT: 112px; POSITION:
absolute; TOP: 48px" runat="server"
Width="176px" Height="22px"></asp:TextBox>
<INPUT id="btnCheck2" style="Z-INDEX: 103; LEFT: 304px; WIDTH: 128px;
POSITION: absolute; TOP: 48px; HEIGHT: 32px"
type="button" value="Check!" name="btnCheck2" onclick="PopUp();">
<asp:Button id="btnCheck" style="Z-INDEX: 104; LEFT: 304px; POSITION:
absolute; TOP: 96px" runat="server"
Width="128px" Height="32px" Text="Check!"></asp:Button>
<asp:Label id="lblCheck" style="Z-INDEX: 105; LEFT: 440px; POSITION:
absolute; TOP: 104px"
runat="server" Width="184px" Height="32px"></asp:Label>
<asp:RequiredFieldValidator id="RequiredFieldValidator1" style="Z-INDEX:
106; LEFT: 144px; POSITION: absolute; TOP: 72px"
runat="server" Width="96px" Height="8px" ErrorMessage="User Name
Missing!" ControlToValidate="txtUser">Required
Field!</asp:RequiredFieldValidator>
</form>
</body>
</HTML>
---this code
behind---
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebApplication1
{
/// <summary>
/// Summary description for WebForm25.
/// </summary>
public class WebForm25 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblUser;
protected System.Web.UI.WebControls.Button btnCheck;
protected System.Web.UI.WebControls.Label lblCheck;
protected System.Web.UI.WebControls.RequiredFieldValidator
RequiredFieldValidator1;
protected System.Web.UI.WebControls.TextBox txtUser;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnCheck.Click += new System.EventHandler(this.btnCheck_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnCheck_Click(object sender, System.EventArgs e)
{
lblCheck.Text = "You selected " + txtUser.Text;
}
}
}
--WebForm26.aspx--
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebApplication1
{
/// <summary>
/// Summary description for WebForm26.
/// </summary>
public class WebForm26 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
string userString = Request.QueryString["User"];
Response.Write("You selected " + userString);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
window.open("WebForm26.aspx?User="+document.getElementById("txtUser").value,
................)
Eliyahu
"Bishoy George" <bishoy@.bishoy.com> wrote in message
news:uVBlP7swFHA.3860@.TK2MSFTNGP09.phx.gbl...
> how to let javascript code understand txtUser.Text?
> in
> window.open("WebForm26.aspx?User=txtUser.Text",................)
>
Thank you , it worked now. You are brilliant.
"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:OrTaxW1wFHA.1132@.TK2MSFTNGP10.phx.gbl...
> window.open("WebForm26.aspx?User="+document.getElementById("txtUser").valu
e,
> ................)
> Eliyahu
> "Bishoy George" <bishoy@.bishoy.com> wrote in message
> news:uVBlP7swFHA.3860@.TK2MSFTNGP09.phx.gbl...
>
passing a parameter to pop up window by javascript how?
in
window.open("WebForm26.aspx?User=txtUser.Text",................)If you use ASP.NET, you can move the entire Javascript to the server side by
using
Page.RegisterStartupScript, and then all server-side variables are available
to be passed to Javascript.
Ryan
"Bishoy George" wrote:
> how to let javascript code understand txtUser.Text?
> in
> window.open("WebForm26.aspx?User=txtUser.Text",................)
>
On Mon, 26 Sep 2005 22:16:25 +0300, Bishoy George wrote:
> how to let javascript code understand txtUser.Text?
> in
> window.open("WebForm26.aspx?User=txtUser.Text",................)
Use
window.open("WebForm26.aspx?User=<%=txtUser.Text%>",....
Could you give me an example please?
still I can't send a parameter through javascript
window.open("url.aspx?-- = --"); // VERY IMPORTANT to me
Also:
Can I write my C# code in the code behind page and just calling a javascript
method by this way?
"Call Javascrip from the server side" <Call Javascrip from the server
side@.discussions.microsoft.com> wrote in message
news:DF3EADAE-E4A8-49C0-AEA0-B58D2D6D2FA4@.microsoft.com...
> If you use ASP.NET, you can move the entire Javascript to the server side
> by
> using
> Page.RegisterStartupScript, and then all server-side variables are
> available
> to be passed to Javascript.
> Ryan
> "Bishoy George" wrote:
>> how to let javascript code understand txtUser.Text?
>> in
>> window.open("WebForm26.aspx?User=txtUser.Text",................)
>>
>>
>
On Mon, 26 Sep 2005 23:46:52 +0300, Bishoy George wrote:
> Could you give me an example please?
> still I can't send a parameter through javascript
> window.open("url.aspx?-- = --"); // VERY IMPORTANT to me
> Also:
> Can I write my C# code in the code behind page and just calling a javascript
> method by this way?
> "Call Javascrip from the server side" <Call Javascrip from the server
> side@.discussions.microsoft.com> wrote in message
> news:DF3EADAE-E4A8-49C0-AEA0-B58D2D6D2FA4@.microsoft.com...
>> If you use ASP.NET, you can move the entire Javascript to the server side
>> by
>> using
>> Page.RegisterStartupScript, and then all server-side variables are
>> available
>> to be passed to Javascript.
>>
>> Ryan
>>
>> "Bishoy George" wrote:
>>
>>> how to let javascript code understand txtUser.Text?
>>> in
>>> window.open("WebForm26.aspx?User=txtUser.Text",................)
>>>
>>>
>>>
The Page.RegisterStartupScript points to a code behind way to do it. The
other way is using inline <%= txtUser.Text %> which is very convenient and
direct.
still doesn't work!!!
-------------this is my aspx
page ------------------
<%@. Page language="c#" Codebehind="WebForm25.aspx.cs"
AutoEventWireup="false" Inherits="WebApplication1.WebForm25" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm25</title>
<script language="javascript">
function PopUp()
{
window.open("WebForm26.aspx?User=<%=txtUser.Text%>","popupWin","toolbar=0,
location=0, status=0, menubar=0, scrollbar=0, resizable=0, width=600,
height=400, left=50, top=50",true);
}
</script>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Label id="lblUser" style="Z-INDEX: 101; LEFT: 24px; POSITION:
absolute; TOP: 48px" runat="server"
Width="80px" Height="22px">User Name:</asp:Label>
<asp:TextBox id="txtUser" style="Z-INDEX: 102; LEFT: 112px; POSITION:
absolute; TOP: 48px" runat="server"
Width="176px" Height="22px"></asp:TextBox>
<INPUT id="btnCheck2" style="Z-INDEX: 103; LEFT: 304px; WIDTH: 128px;
POSITION: absolute; TOP: 48px; HEIGHT: 32px"
type="button" value="Check!" name="btnCheck2" onclick="PopUp();">
<asp:Button id="btnCheck" style="Z-INDEX: 104; LEFT: 304px; POSITION:
absolute; TOP: 96px" runat="server"
Width="128px" Height="32px" Text="Check!"></asp:Button>
<asp:Label id="lblCheck" style="Z-INDEX: 105; LEFT: 440px; POSITION:
absolute; TOP: 104px"
runat="server" Width="184px" Height="32px"></asp:Label>
<asp:RequiredFieldValidator id="RequiredFieldValidator1" style="Z-INDEX:
106; LEFT: 144px; POSITION: absolute; TOP: 72px"
runat="server" Width="96px" Height="8px" ErrorMessage="User Name
Missing!" ControlToValidate="txtUser">Required
Field!</asp:RequiredFieldValidator>
</form>
</body>
</HTML
------------this code
behind--------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebApplication1
{
/// <summary
/// Summary description for WebForm25.
/// </summary
public class WebForm25 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblUser;
protected System.Web.UI.WebControls.Button btnCheck;
protected System.Web.UI.WebControls.Label lblCheck;
protected System.Web.UI.WebControls.RequiredFieldValidator
RequiredFieldValidator1;
protected System.Web.UI.WebControls.TextBox txtUser;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary
private void InitializeComponent()
{
this.btnCheck.Click += new System.EventHandler(this.btnCheck_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnCheck_Click(object sender, System.EventArgs e)
{
lblCheck.Text = "You selected " + txtUser.Text;
}
}
}
--------WebForm26.aspx--------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebApplication1
{
/// <summary
/// Summary description for WebForm26.
/// </summary
public class WebForm26 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
string userString = Request.QueryString["User"];
Response.Write("You selected " + userString);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
window.open("WebForm26.aspx?User="+document.getElementById("txtUser").value,
.................)
Eliyahu
"Bishoy George" <bishoy@.bishoy.com> wrote in message
news:uVBlP7swFHA.3860@.TK2MSFTNGP09.phx.gbl...
> how to let javascript code understand txtUser.Text?
> in
> window.open("WebForm26.aspx?User=txtUser.Text",................)
Thank you , it worked now. You are brilliant.
"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:OrTaxW1wFHA.1132@.TK2MSFTNGP10.phx.gbl...
> window.open("WebForm26.aspx?User="+document.getElementById("txtUser").value,
> ................)
> Eliyahu
> "Bishoy George" <bishoy@.bishoy.com> wrote in message
> news:uVBlP7swFHA.3860@.TK2MSFTNGP09.phx.gbl...
>> how to let javascript code understand txtUser.Text?
>> in
>> window.open("WebForm26.aspx?User=txtUser.Text",................)
>>
>>