|
Hi there. Here is a simple example of a user control that fires events. The first file is a user control, the second is an .aspx page that consumes it. I hope this is helpful.
file events2_uc1.ascx:
<%@ Control language="VB" %>
<script runat="server">
public event OKClicked as EventHandler
public event CancelClicked as EventHandler
Protected Overridable Sub OnOKClicked(args as EventArgs)
RaiseEvent OKClicked(Me, args)
End Sub
Protected Overridable Sub OnCancelClicked(args as EventArgs)
RaiseEvent CancelClicked(Me, args)
End Sub
Private Sub btnOK_Click(o as Object, e as EventArgs)
OnOKClicked(new EventArgs())
End Sub
Private Sub btnCancel_Click(o as Object, e as EventArgs)
OnCancelClicked(new EventArgs())
End Sub
</script>
<asp:Button id="btnOK" runat="server" text="OK"
OnClick="btnOK_Click"
/>
<asp:Button id="btnCancel" runat="server" text="Cancel"
OnClick="btnCancel_Click"
/>
file events2.aspx:
<%@ Page Language="VB" %>
<%@ Register TagPrefix="uc" TagName="Buttons" Src="events2_uc1.ascx" %>
<script runat="server">
Sub OKClicked(o as object, e as EventArgs)
label1.Text = "The OKClicked event was fired in the user control"
End Sub
Sub CancelClicked(o as object, e as EventArgs)
label1.Text = "The CancelClicked event was fired in the user control"
End Sub
</script>
<html>
<head>
<title></title>
</head>
<body>
<form runat="server">
<h3>Testing events from a user control</h3>
<hr />
The following is a user control:
<br />
<uc:Buttons runat="server"
OnOKClicked="OKClicked"
OnCancelClicked="CancelClicked"
/>
<br /><br />
<asp:Label id="label1" runat="server" text="" />
</form>
</body>
</html>
|
|
|
|
|
Like this:
http://www.samspublishing.com/articles/article.asp?p=23020&rl=1
|
|
|
|
|
Why Application_PostAuthenticateRequest and Application_AuthenticateRequest events happen twice ? When I put a breakpoint in their code I see that when I run the application they are called twice ? Can someone tell me why they have to be called twice ? Illustrating their position in the asp.net's events flowchart will be helpful . Help me please .
|
|
|
|
|
Hi,
In my project,due to large number of records a stored procedure is taking more time to return the records.But before that the connection time expires and the module will show the error message.Since the project is deployed in the site we cannot recompile after code change.Is there any way to set in web.config to get more sql connection time.
Please show me the right way..Thanks much in advance.
Thank You,
RPM.
|
|
|
|
|
You can set the CommandTimeout[^] property of your SqlCommand object to a higher number before executing.
|
|
|
|
|
Hi Mike Ellison,
Thanks a lot for the reply and information.But this requires code change.Our project is deployed in the production server.So without a code change and only change in web.config can we incorporate this?
Any possibility is there?
Thanks very much,
RPM.
|
|
|
|
|
Well, you can always store values in AppSettings in your web.config, then read those values in your application... granted, that involves a code change initially, but after that then you can set your timeout values through web.config.
|
|
|
|
|
I have faced the similar problem in my application. To change the connection timeout property in the query string won't solve the issue. You have to change on the code, imagine you are using an command object and executing a stored procedure, you have to set the CommandTimeout property of the command object to some time (Seconds). It is working for me. I tried with web.config connection timeout property of the connection string, it was not working.
Example:
========
SqlCommand oCmd = new SqlCommand("Procedure1", oConn);
oCmd.CommandType = CommandType.StoredProcedure;
oCmd.CommandTimeout = 300;
SqlDataAdapter oAdp = new SqlDataAdapter(oCmd);
|
|
|
|
|
hi,
i have seen some of the datagrid samples in internet. In most of the cases the datagrid is bind to some table. But if i want to display the output of an sql query(contains select statement with n number of columns) in Datagrid, i can simply use AutogenerateColumns=true and populate the datagrid without having any bound columns. That is fine.
If i want to add some more extra columns like a checkbox column and an edit link button column i can do it using property builder. But,the problem is how can i order the columns in datagrid.
for example: 1st col: checkboxes
2nd-4th col : from sql statemnt
5th col : edit link button
Also how can i make a random column from sql statement to a hyperlink column.
thanks
|
|
|
|
|
One simplest way is, add few temprory columns in the query, wherever you want add column in the grid. Then bind that query result to the datagrid.
Example:
========
Actual query is,
select column1, column2, column3 from table1
Imagine you want to add columns in between 1 and 2, 2 and 3 then the query should be,
select column1, '' as tempcol1, column2, '' as tempcol2, column3 from table1
then on the itemdatabound event you can add any control like (button, linkbutton, or dropdownlist) on the column.
Ram
|
|
|
|
|
can you please explain a bit about the modified query.
|
|
|
|
|
Example:
========
Actual query is,
select column1, column2, column3 from table1
Imagine you want to add columns in between 1 and 2, 2 and 3 then the query should be,
select column1, '' as tempcol1, column2, '' as tempcol2, column3 from table1
then on the itemdatabound event you can add any control like (button, linkbutton, or dropdownlist) on the column
Explanation:
============
You just execute the these two queries. First query will return three columns, second query will return five columns. The temp columns are not available in any table, which will be used to create a column in the grid. You just execute this queries in the query analyzer and check.
Ram
|
|
|
|
|
Please help me to find a tool to convert barcode no. to picture in crystal report to print it
thanks for all
|
|
|
|
|
Does anyone know how the the HTTP Headers property 'Enable content expiration' set to Expires immediately can be programmed using C#?
Advance thanks for your reply
|
|
|
|
|
can any one plz,send me a good URL to learn SESSIONS,COOKIES from BASICS in ASP.NET using C#
|
|
|
|
|
|
|
Hi,
I have a problem with event on LinkButton inside my TemplateField of GridView which is programmatically created.
When I create GridView's TemplateField, I use special class that inherits from ITemplate.
In this class I try to create LinkButton for every row of GridView.
This is my code:
class GridViewTemplate : System.Web.UI.Page, ITemplate<br />
{<br />
ListItemType templateType;<br />
string columnName;<br />
<br />
void ITemplate.InstantiateIn(System.Web.UI.Control container)<br />
{<br />
switch (templateType)<br />
{<br />
case ListItemType.Item:<br />
LinkButton lbtn = new LinkButton();<br />
lbtn.DataBinding += new EventHandler(Object_DataBinding);<br />
lbtn.CssClass = "TextBlackBold";<br />
lbtn.Command += new CommandEventHandler(this.TakeTaskLinkButton_OnCommand);<br />
lbtn.CommandName = "SubmitTakeTaskLinkButtonCommandName";<br />
container.Controls.Add(lbtn);<br />
break;<br />
}<br />
}<br />
<br />
void Object_DataBinding(object sender, EventArgs e)<br />
{<br />
LinkButton lbtn = (LinkButton)sender;<br />
GridViewRow container = (GridViewRow)lbtn.NamingContainer;<br />
lbtn.ID = "TakeTaskLinkButton" + DataBinder.Eval(container.DataItem, "taskid").ToString();<br />
lbtn.Text = DataBinder.Eval(container.DataItem, "tasktitle").ToString();<br />
lbtn.CommandArgument = DataBinder.Eval(container.DataItem, "taskid").ToString();<br />
}<br />
<br />
void TakeTaskLinkButton_OnCommand(object sender, CommandEventArgs e)<br />
{<br />
switch (e.CommandName)<br />
{<br />
case "SubmitTakeTaskLinkButtonCommandName":<br />
Response.Redirect("Default.aspx");<br />
break;<br />
}<br />
}<br />
<br />
public GridViewTemplate(ListItemType type, string colName)<br />
{<br />
templateType = type;<br />
columnName = colName;<br />
}<br />
}
and the TakeTaskLinkButton_OnCommand method is not fired when I click on the LinkButton.
I don't know why!? Any suggestions? How can I solve this problem?
Regards,
(Sorry for any mistakes)
MarcinG
|
|
|
|
|
My DataTable contains values to bind to the GridView. In GridView, i am having a TextBox, how can i display the value( from DataTable) in that TextBox. Also i wish to Read that..
Incase of <asp:bouncontrol>, it has the property called DataField. Itz no problem for me.
Anybody can help me?
Regards,
Jay
|
|
|
|
|
|
I have used TemplateField for this & Got it. Thanks for your Info Mr.Mike.
Regards,
Jay
|
|
|
|
|
hello
i'm making a appliocation in asp.net with vb.
i have to use PayPal and 2checkout.com for Payment.I have already downloaded the Paypal component for Asp.Net but i'm getting how to use it.
We hav Four Plans.for 1$, 3$,5$,7$. I just Want when any user choose any plan then he can can pay the payment through the Above Method and I have to keep the Account or Information that which user have paid the money or not.
Plz Guide me in this matter.
thanx
|
|
|
|
|
I'd recommend maybe having a wee look at the PayPal site. They must have some information there on how to do this...
|
|
|
|
|
Yes paypal has got .net SDK which can be use to connect to paypal server and do all the validation.
|
|
|
|
|
hello thanx for reply
i have download the SDk but not getting how to use.
i have seen some of the example too.
but they were not very useful to me.
what i have to do just pay the payment after calculation.
in my website there is no such Add to Cart Like thing.
user just can click on the plan and for how many month he want this plan.
suppose one plan cost is 1$ for a month.if he select For 2 Month.then total amount is 2$.
now how to payment this 2$ using paypal.
if u hav some REF: Code then plz send me if possible otherwise guide me.
thanx
i will wait for ur reply.
|
|
|
|