Showing posts with label default. Show all posts
Showing posts with label default. Show all posts

Thursday, March 29, 2012

Passing values from a child window

hi all,
I have a parent window default.aspx which has a textbox(txtBox1) with
multiline property and a button.when the button is clicked a child
window pops up child.aspx.
I have four textboxes in child.aspx and a submit button.What I want to
happen is when I click the submit button all the values must be
displayed in the multiline textbox in a table format with header and
the values below or any formatted display with headers.
I am using,
window.opener.documents.forms[0].txtBox1.value method to pass the
values.
can anybody help me to fix the values from the child window to the
parent window in a formatted display.I have been trying this for a day.
thanksHello ssrivani@.gmail.com,
From what I understood, after opening the child window and filling in the ch
ild form, you want to be able to:
1- Format the form field values in an html table.
2- copy the resulting html to the opening window and have it inserted into t
he multi line text field.
Try the attached files and see if it works for you.

> hi all,
>
> I have a parent window default.aspx which has a textbox(txtBox1) with
> multiline property and a button.when the button is clicked a child
> window pops up child.aspx.
> I have four textboxes in child.aspx and a submit button.What I want to
> happen is when I click the submit button all the values must be
> displayed in the multiline textbox in a table format with header and
> the values below or any formatted display with headers.
> I am using,
> window.opener.documents.forms[0].txtBox1.value method to pass the
> values.
> can anybody help me to fix the values from the child window to the
> parent window in a formatted display.I have been trying this for a
> day.
>
> thanks
>

Monday, March 26, 2012

Passing values to Stored Procedure

I have a C#.NET that simply passes 6 values to a Stored Procedure. But
I'm trying to get the (Default.aspx.cs page) to handle passing the
values to the sp. The goal is to pass the values and see if any
records are returned. I will later insert some conditional statements.
Here is my Default.aspx.cs
protected void btnNext_Click(object sender, EventArgs e)
{
Session["TotalTimeTo"] = TotalTimeTo.Text;
Session["TotalTimeFrom"] = TotalTimeFrom.Text;
Session["Locations"] = Locations.Text;
Session["Mh"] = Mh.Text;
Session["Dy"] = Dy.Text;
Session["Yr"] = Yr.Text;
Server.Transfer("page3.aspx");
/* Trying to pass to SP*/
string connectionStr =
@dotnet.itags.org." server=localhost;uid=user;pwd=pass;trust
ed_connection=true;database=Events
";
SqlConnection connectObj = new SqlConnection(connectionStr);
commandObj.Connection.Open();
commandObj.ExecuteNonQuery();
commandObj.Connection.Close();
}
Here is my stored procedure*********************
CREATE PROCEDURE CheckAvailableEvents
@dotnet.itags.org.Yr nvarchar(4)
,@dotnet.itags.org.Mh nvarchar(2)
,@dotnet.itags.org.Dy nvarchar(2)
,@dotnet.itags.org.Locations nvarchar(50)
,@dotnet.itags.org.TotalTimeTo nvarchar(12)
,@dotnet.itags.org.TotalTimeFrom nvarchar(12)
As
IF (SELECT Count(TotalTimeTo) from SpecialEvents Where ((Yr = @dotnet.itags.org.Yr) AND
(Mh = @dotnet.itags.org.Mh) AND (Dy = @dotnet.itags.org.Dy))
AND Locations = @dotnet.itags.org.Locations AND TotalTimeTo = @dotnet.itags.org.TotalTimeTo ) > 0
Select Top 1 Locations, TotalTimeTo, ContactPerson, Extension from
SpecialEvents Where ((Yr = @dotnet.itags.org.Yr) AND (Mh = @dotnet.itags.org.Mh) AND (Dy = @dotnet.itags.org.Dy))
AND Locations = @dotnet.itags.org.Locations AND TotalTimeTo = @dotnet.itags.org.TotalTimeTo
ELSE
Select Top 0 Locations from SpecialEvents
I get a little lost because a lot of the online tutorials are passing
the values to SqlAdapters!Try this. It uses "using" to implicitly clean up all your DB stuff when
disposed:
using (SqlCommand command = new SqlCommand(new SqlConnection(...)))
{
command.Parameters.Add("@.Param1", param1);
command.Parameters.Add("@.Param2", param2);
SqlParameter returnValue = new SqlParameter("@.Identity",
SqlDbType.BigInt);
returnValue.Direction = ParameterDirection.Output;
command.Parameters.Add(returnValue);
command.ExecuteNonQuery();
return (Int64) returnValue.Value;
}

Passing values to Stored Procedure

I have a C#.NET that simply passes 6 values to a Stored Procedure. But
I'm trying to get the (Default.aspx.cs page) to handle passing the
values to the sp. The goal is to pass the values and see if any
records are returned. I will later insert some conditional statements.

Here is my Default.aspx.cs

protected void btnNext_Click(object sender, EventArgs e)
{

Session["TotalTimeTo"] = TotalTimeTo.Text;
Session["TotalTimeFrom"] = TotalTimeFrom.Text;
Session["Locations"] = Locations.Text;

Session["Mh"] = Mh.Text;
Session["Dy"] = Dy.Text;
Session["Yr"] = Yr.Text;
Server.Transfer("page3.aspx");
/* Trying to pass to SP*/

string connectionStr =
@dotnet.itags.org."server=localhost;uid=user;pwd=pass;trusted_connect ion=true;database=Events";

SqlConnection connectObj = new SqlConnection(connectionStr);

commandObj.Connection.Open();
commandObj.ExecuteNonQuery();
commandObj.Connection.Close();
}

Here is my stored procedure*********************

CREATE PROCEDURE CheckAvailableEvents
@dotnet.itags.org.Yr nvarchar(4)
,@dotnet.itags.org.Mh nvarchar(2)
,@dotnet.itags.org.Dy nvarchar(2)
,@dotnet.itags.org.Locations nvarchar(50)
,@dotnet.itags.org.TotalTimeTo nvarchar(12)
,@dotnet.itags.org.TotalTimeFrom nvarchar(12)
As
IF (SELECT Count(TotalTimeTo) from SpecialEvents Where ((Yr = @dotnet.itags.org.Yr) AND
(Mh = @dotnet.itags.org.Mh) AND (Dy = @dotnet.itags.org.Dy))
AND Locations = @dotnet.itags.org.Locations AND TotalTimeTo = @dotnet.itags.org.TotalTimeTo ) 0

Select Top 1 Locations, TotalTimeTo, ContactPerson, Extension from
SpecialEvents Where ((Yr = @dotnet.itags.org.Yr) AND (Mh = @dotnet.itags.org.Mh) AND (Dy = @dotnet.itags.org.Dy))
AND Locations = @dotnet.itags.org.Locations AND TotalTimeTo = @dotnet.itags.org.TotalTimeTo

ELSE

Select Top 0 Locations from SpecialEvents

I get a little lost because a lot of the online tutorials are passing
the values to SqlAdapters!Try this. It uses "using" to implicitly clean up all your DB stuff when
disposed:
using (SqlCommand command = new SqlCommand(new SqlConnection(...)))
{
command.Parameters.Add("@.Param1", param1);
command.Parameters.Add("@.Param2", param2);
SqlParameter returnValue = new SqlParameter("@.Identity",
SqlDbType.BigInt);

returnValue.Direction = ParameterDirection.Output;
command.Parameters.Add(returnValue);
command.ExecuteNonQuery();

return (Int64) returnValue.Value;
}

Saturday, March 24, 2012

passing variables between controls

I have a default page that loads a few web user controls like below

pnl_header.Controls.Add(Page.LoadControl("control\\header.ascx"));
pnl_body.Controls.Add(Page.LoadControl("control\\list_topic.ascx"));

And I have some information which is the same for each control and I do not want to do a SQL call every time for each control so I was wondering what is the best way to call the info once and then share the information between all the controls.

TIA.
AlvinYou could call on the sql on the first application load event. Then you could add the object to cache.

Cache["myCache"] = myDataSet; // for instance

if(Cache["myCache"]==null){

// Call a method to create the cache

}
esle{

myNewDataSet = (DataSet) Cache["myCache"];
}

Then you can retrieve the info from cache instead of hitting the db everytime.

You could also look at CacheDependencies as you can have the cache automatically refresh based on a change event - although this may not be necessary since you connecting to a db.

Hope that helps
This is just what I needed. Thanks Keith