Showing posts with label created. Show all posts
Showing posts with label created. Show all posts

Monday, March 26, 2012

pass the arguments from web to windows

Hi all,
I have created one web applicatication which contains button.When I
click the button
I want to pass arguments to windows application.Can I do it?Any one
please help me...
Regards justinHi,
How about this code:

string strArg = @." the arguments comes here";

process.StartInfo.Arguments = strArg;

process.StartInfo.UseShellExecute = false;

process.StartInfo.RedirectStandardOutput = true;

try

{

process.Start();

}

catch(Exception ex)

{

string str = ex.Source + ex.Message + ex.StackTrace;

}

Thanks and Regards,
Manish Bafna.
MCP and MCTS.

"justin" wrote:

Quote:

Originally Posted by

Hi all,
I have created one web applicatication which contains button.When I
click the button
I want to pass arguments to windows application.Can I do it?Any one
please help me...
Regards justin
>
>


The simplest (or one of the simplest) way of communicating between
applications is via text files. One guy writes, another reads.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"justin" <justindhasy@.gmail.comwrote in message
news:1166424002.419061.231640@.j72g2000cwa.googlegr oups.com...

Quote:

Originally Posted by

Hi all,
I have created one web applicatication which contains button.When I
click the button
I want to pass arguments to windows application.Can I do it?Any one
please help me...
Regards justin
>

pass the arguments from web to windows

Hi all,
I have created one web applicatication which contains button.When I
click the button
I want to pass arguments to windows application.Can I do it?Any one
please help me...
Regards justinHi,
How about this code:
string strArg = @." the arguments comes here";
process.StartInfo.Arguments = strArg;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
try
{
process.Start();
}
catch(Exception ex)
{
string str = ex.Source + ex.Message + ex.StackTrace;
}
Thanks and Regards,
Manish Bafna.
MCP and MCTS.
"justin" wrote:

> Hi all,
> I have created one web applicatication which contains button.When I
> click the button
> I want to pass arguments to windows application.Can I do it?Any one
> please help me...
> Regards justin
>
The simplest (or one of the simplest) way of communicating between
applications is via text files. One guy writes, another reads.
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"justin" <justindhasy@.gmail.com> wrote in message
news:1166424002.419061.231640@.j72g2000cwa.googlegroups.com...
> Hi all,
> I have created one web applicatication which contains button.When I
> click the button
> I want to pass arguments to windows application.Can I do it?Any one
> please help me...
> Regards justin
>

Saturday, March 24, 2012

Pass Variables from one page to another

is there a way to pass variables from one page to another.
I created one page where the user makes selections by ddl and textboxes. I want to be able to pass the selections to a second page of a datalist to display the results.

thanksStore the values of the variables in session variables. You can then access them on your second page.
Request.Form is still available.
what do you mean request.Form is still available?
what do you mean session variables?
Request.Form["TheNameOfYourFormField"] will give you the values of your fields, like in ASP.
Request.Form would only work (as far as I am aware) if you your posting page is an HTML form and not a web form, a web form will overide the form action attribute and postback. Is this right?

Use session like this:

Session("MyValue") = "xxx" 'sets your value

Dim MyValue As String = Session("MyValue") 'gets the value back on another page

or look at this method that I quite like -MSDN passing values between web forms pages

Simon

Pass VB Variable to ASP Control Property

Hi everyone,

this must be easy, but I can't get it right.

How do I pass the VBvariable created at page_load to the property of a
web control:

....
<asp:DropDownList ID="cbo1" runat="server" DataSourceID="SqlDataSource1"
DataTextField="<%=VBVariable%>"
....

What is the correct syntax for DataTextField="<%=VBVariable%>"?

Best regards

Robert"Robert Bevington" <rbevington@.freenet.dewrote in message
news:u8YBYzLxHHA.4612@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

Hi everyone,
>
this must be easy, but I can't get it right.
>
How do I pass the VBvariable created at page_load to the property of a web
control:
>
...
<asp:DropDownList ID="cbo1" runat="server" DataSourceID="SqlDataSource1"
DataTextField="<%=VBVariable%>"
...
>
What is the correct syntax for DataTextField="<%=VBVariable%>"?


Looks OK to me - what error(s) are you getting...?

Also, I'm assuming that VBVariable *does* actually contain a value... :-)

--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Hi Mark,

If I hard code the variable everything works fine. If Then replace the
text "ATT_Department" with "<%=VBVariable%>", I got the following message:

DataBinding: System.Data.DataRowView enthlt keine Eigenschaft mit dem
Namen <%=ATT_Name %>.

Translated to English: DataBinding: System.Data.DataRowView has no
property named <%=ATT_Name %>

In Debug mode, if I place the mouse over the variable it reads
"ATT_Department". So it does have a value.

Any ideas?

Rob

Mark Rae [MVP] schrieb:

Quote:

Originally Posted by

"Robert Bevington" <rbevington@.freenet.dewrote in message
news:u8YBYzLxHHA.4612@.TK2MSFTNGP04.phx.gbl...
>

Quote:

Originally Posted by

>Hi everyone,
>>
>this must be easy, but I can't get it right.
>>
>How do I pass the VBvariable created at page_load to the property of a
>web control:
>>
>...
><asp:DropDownList ID="cbo1" runat="server" DataSourceID="SqlDataSource1"
> DataTextField="<%=VBVariable%>"
>...
>>
>What is the correct syntax for DataTextField="<%=VBVariable%>"?


>
Looks OK to me - what error(s) are you getting...?
>
Also, I'm assuming that VBVariable *does* actually contain a value... :-)
>
>

Pass VB Variable to ASP Control Property

Hi everyone,
this must be easy, but I can't get it right.
How do I pass the VBvariable created at page_load to the property of a
web control:
...
<asp:DropDownList ID="cbo1" runat="server" DataSourceID="SqlDataSource1"
DataTextField="<%=VBVariable%>"
...
What is the correct syntax for DataTextField="<%=VBVariable%>"?
Best regards
Robert"Robert Bevington" <rbevington@.freenet.de> wrote in message
news:u8YBYzLxHHA.4612@.TK2MSFTNGP04.phx.gbl...

> Hi everyone,
> this must be easy, but I can't get it right.
> How do I pass the VBvariable created at page_load to the property of a web
> control:
> ...
> <asp:DropDownList ID="cbo1" runat="server" DataSourceID="SqlDataSource1"
> DataTextField="<%=VBVariable%>"
> ...
> What is the correct syntax for DataTextField="<%=VBVariable%>"?
Looks OK to me - what error(s) are you getting...?
Also, I'm assuming that VBVariable *does* actually contain a value... :-)
Mark Rae
ASP.NET MVP
http://www.markrae.net
Hi Mark,
If I hard code the variable everything works fine. If Then replace the
text "ATT_Department" with "<%=VBVariable%>", I got the following message:
DataBinding: System.Data.DataRowView enthlt keine Eigenschaft mit dem
Namen <%=ATT_Name %>.
Translated to English: DataBinding: System.Data.DataRowView has no
property named <%=ATT_Name %>
In Debug mode, if I place the mouse over the variable it reads
"ATT_Department". So it does have a value.
Any ideas?
Rob
Mark Rae [MVP] schrieb:
> "Robert Bevington" <rbevington@.freenet.de> wrote in message
> news:u8YBYzLxHHA.4612@.TK2MSFTNGP04.phx.gbl...
>
> Looks OK to me - what error(s) are you getting...?
> Also, I'm assuming that VBVariable *does* actually contain a value... :-)
>
"Robert Bevington" <rbevington@.freenet.de> wrote in message
news:%23zKYDJMxHHA.3652@.TK2MSFTNGP04.phx.gbl...

> If I hard code the variable everything works fine. If Then replace the
> text "ATT_Department" with "<%=VBVariable%>", I got the following message:
> DataBinding: System.Data.DataRowView enthlt keine Eigenschaft mit dem
> Namen <%=ATT_Name %>.
> Translated to English: DataBinding: System.Data.DataRowView has no
> property named <%=ATT_Name %>
> In Debug mode, if I place the mouse over the variable it reads
> "ATT_Department". So it does have a value.
> Any ideas?
How are you declaring the server-side variable? In order to visible to the
aspx page, server-side variables need to be Public or Protected.
Mark Rae
ASP.NET MVP
http://www.markrae.net

Wednesday, March 21, 2012

passing a Guid to a button class

Hi i have a linkbutton created with C# that needs to call a class and pass a guid through to that class i have tried to use

public void buttonClass(string guid,object sender,Eventargs e)
but it does work i get an error so how do i pass a guid to this class form my button ( code below)

1//button class2public void prodAdd(object sender, EventArgs e)3 {4 checkoutFunctions cartAdd =new checkoutFunctions();5string userGuid = cartAdd.userFind(HttpContext.Current.User.Identity.Name);6 cartAdd.addItem(prodGuid, userGuid);7 Response.Redirect("cart.aspx");8 }910// BUtton generator11 mediaSelect.Controls.Add(new LiteralControl("<a href='#' onClick=\"flashshowHide('" + mediaId + "')\">" + medRead["media_name"].ToString().Replace("#@dotnet.itags.org.","'") +"<span class='prevBut'>(preview)</span></a>"));12 Button buyProd =new Button();13 buyProd.Text = ("Download for £" + medRead["media_price"].ToString());14 buyProd.Click +=new EventHandler(prodAdd);15 mediaSelect.Controls.Add(buyProd);16 mediaSelect.Controls.Add(new LiteralControl("<br/>"));
Thanks
Dan 

I think you must be missing something here conceptually. The prodAdd isnt a button class, it's an event handler that you're wiring up to handle the click event of your dynamically created button. That set of code will run only when the button is clicked. If you need to pass a GUID to it, pass it from wherever it was clicked at, not when the button is created.


yes ok but how do i set it to send the guid to the class when it is clicked


It's not a class - it's an event handler. You are going to have issues till you can get your terminology correct.

Try

buyProd.commandArgument = yourGUID

then in your event handler you can get the guid by using

e.commandArgument

passing a parameter?

Hi Guys,

I am just starting on ASP.net. I have created this file so far called database.aspx. The file contains this code:


<%@dotnet.itags.org. Page Language="C#" %>
<script runat="server">


void Page_load(object Sender, EventArgs e)
{

// Discover if SKU QueryString contains a value
string SKU = Request.QueryString["SKU"];
if (SKU == "")
Response.Write ("NO SKU");
else
DataGrid1.DataSource = GetProduct();
DataGrid1.DataBind();
}

System.Data.DataSet GetProduct() {

// Connect to Database
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\\test\\database\\test.mdb";
System.Data.IDbConnection dbConnection = new System.Data.OleDb.OleDbConnection(connectionString);

// SQL
string queryString = "SELECT [Products].Title FROM [Products] WHERE ([Products].SKU = @dotnet.itags.org.SKU)";
System.Data.IDbCommand dbCommand = new System.Data.OleDb.OleDbCommand();
dbCommand.CommandText = queryString;
dbCommand.Connection = dbConnection;

//Request SKU # from Querystring then locate prodcut based on SKU #

System.Data.IDataParameter dbParam_SKU = new System.Data.OleDb.OleDbParameter();
dbParam_SKU.ParameterName = "@dotnet.itags.org.SKU";
dbParam_SKU.Value = SKU;
dbParam_SKU.DbType = System.Data.DbType.Int32;
dbCommand.Parameters.Add(dbParam_SKU);


System.Data.IDbDataAdapter dataAdapter = new System.Data.OleDb.OleDbDataAdapter();
dataAdapter.SelectCommand = dbCommand;
System.Data.DataSet dataSet = new System.Data.DataSet();
dataAdapter.Fill(dataSet);

return dataSet;


}

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<br />
<br />
<asp:DataGrid id="DataGrid1" runat="server"></asp:DataGrid>
<!-- Insert content here -->
</form>
</body>
</html>

I am trying to pass the SKU from the page_load into the GetProducts();

Can someone please help me as I have been trying to work this out all afternoon.

Thanks for the help (any other comments about how to speed up or improve the code are much appricitated).Big Smile [:D]

Muller


<%@. Page Language="C#" %>
<script runat="server">


void Page_load(object Sender, EventArgs e)
{

// Discover if SKU QueryString contains a value
string SKU = Request.QueryString["SKU"];
if (SKU == "")
Response.Write ("NO SKU");
else

{
DataGrid1.DataSource = GetProduct(SKU);
DataGrid1.DataBind();

}
}

System.Data.DataSet GetProduct(String SKU) {

// Connect to Database
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\\test\\database\\test.mdb";
System.Data.IDbConnection dbConnection = new System.Data.OleDb.OleDbConnection(connectionString);

// SQL
string queryString = "SELECT [Products].Title FROM [Products] WHERE ([Products].SKU = @.SKU)";
System.Data.IDbCommand dbCommand = new System.Data.OleDb.OleDbCommand();
dbCommand.CommandText = queryString;
dbCommand.Connection = dbConnection;

//Request SKU # from Querystring then locate prodcut based on SKU #

System.Data.IDataParameter dbParam_SKU = new System.Data.OleDb.OleDbParameter();
dbParam_SKU.ParameterName = "@.SKU";
dbParam_SKU.Value = SKU;
dbParam_SKU.DbType = System.Data.DbType.Int32;
dbCommand.Parameters.Add(dbParam_SKU);


System.Data.IDbDataAdapter dataAdapter = new System.Data.OleDb.OleDbDataAdapter();
dataAdapter.SelectCommand = dbCommand;
System.Data.DataSet dataSet = new System.Data.DataSet();
dataAdapter.Fill(dataSet);

return dataSet;


}

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<br />
<br />
<asp:DataGrid id="DataGrid1" runat="server"></asp:DataGrid>
<!-- Insert content here -->
</form>
</body>
</html>


Im not a C# programmer so the syntax might be wrong, but I would pass the SKU in as a parameter to the GetProduct routine...like GetProduct(SKU)

and update the query to something like:
string queryString = "SELECT [Products].Title FROM [Products] WHERE ([Products].SKU = " + SKU + ")";

Of course, you would need to change the function so you could pass in the SKU...OR you could create a module level variable and change that variable in your page load, and use it in your function.

MajorCats


thankswessamzeidan that works great.

MajorCats - Thats exactly the way I use to do it in ASP but in one of my ASP.NET books it says to do it this way to try and reduce the risk of SQL injection attacks. I need to look into this more but if anyone has any thoughts please email/reply to this postBig Smile [:D]

Thanks again

Muller