|
Make your method return a value which you can use to determine wether the business logic code succeeded or not
public bool DoSomething()
{
bool result = false;
try
{
result = true;
}
catch
{
result = false;
}
return result;
}
and then on your asp page check wether the function failed or not
if (DoSomething())
{
}
else
{
Respone.Redirect("Error.aspx");
}
|
|
|
|
|
|
|
Hi,
I want to populate Month like Nov-2010,Dec-2010 etc.. in DropDownList. It will show current financial year and so on....
Can any one help me regarding this.
Thanks...
|
|
|
|
|
I dont know, Might be some third party control can provide you month in this format. You your self can create the month like this and bind it to the dwopdown,
Or you can hardcode it in a file and bind it from there when require.
|
|
|
|
|
Thanks for reply. But, I don't want to hardcodeit. I simply want to read system date.
|
|
|
|
|
TRy like this in Database
select convert(varchar(3),datename(mm,getdate()),24) + '--' + convert(varchar(4),datename(yy,getdate()),24)
|
|
|
|
|
5
♫ 99 little bugs in the code,
99 bugs in the code
We fix a bug, compile it again
101 little bugs in the code ♫
|
|
|
|
|
Hi,
I have a gridview with Edit And Delete buttons.
Here is one of the columns:
<asp:TemplateField HeaderText="החל מ-">
<EditItemTemplate>
<asp:TextBox ID="txtStart" Width="150px" ReadOnly="true" BackColor="LightSteelBlue" runat="server" Text='<%# Bind("startHour") %>'></asp:TextBox></EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtStartNew" Width="150px" runat="server"></asp:TextBox></FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblMStart" Width="150px" runat="server" Text='<%# Bind("startHour") %>'></asp:Label></ItemTemplate>
</asp:TemplateField>
I've set the TextBox in the EditItemTemplate to ReadOnly.
My Problem is-
that i want to change the property (ReadOnly) to False after i pressed on the Edit button if some cell has a value.
I've tried to do this in the RowEditing event -
TextBox txtStart = (TextBox)GridViewIpTab.Rows[e.RowIndex].FindControl("txtStart");
but i got "Object reference not set to an instance of an object".
Can some one please help me with this problem?
|
|
|
|
|
Have you debugged it?
I would more than likely handle this on the client-side with some JavaScript.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark Nischalke wrote: I would more than likely handle this on the client-side with some JavaScript.
What you suggest to do?
I never did javascript on grid...
|
|
|
|
|
treuveni wrote: What you suggest to do?
learn JavaScript.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark Nischalke wrote:
learn JavaScript.
10x,
great answer
|
|
|
|
|
You might try doing this in RowDataBound event:
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (GridViewIpTab.EditIndex == e.Row.RowIndex)
{
TextBox txtStart = (TextBox)GridViewIpTab.Rows[e.Row.RowIndex].FindControl("txtStart");
}
}
In RowEditing do:
GridViewIpTab.EditIndex = e.NewEditIndex;
BindYourGrid();
- S
50 cups of coffee and you know it's on!
Code, follow, or get out of the way.
|
|
|
|
|
You can reference this example:
protected void gv4PPdata_RowDataBound(object sender, GridViewRowEventArgs e)
{
if((e.Row.RowState & DataControlRowState.Edit) > 0)
{
TextBox curText;
for (int i = 1; i <= 6; i++)
{
curText = (TextBox)e.Row.Cells[i].Controls[0];
curText.Width = Unit.Pixel(60);
if (i == 1)
{
curText.Enabled = false;
}
}
}
}
Reference: http://www.programlive.tk
|
|
|
|
|
Hi.
I'm creating a web app with ajax.
I added tab control(from jquery ui) that enables to add tabs dynamically.
So if the user wants for example to add a new customer he will open a new tab with the "add customer form".
Now, if i open a couple of this tabs i have a problem with conflicting id's because each tab that opens receives from the server a chunk of ready html that contains a form with controls that some of them have a id's.
My question is , what are the main techniques to add lots of html to a single aspx page that avoids confilicting id's and etc.
Thanks.
|
|
|
|
|
Obviously you need to maintain a count of the number of controls and increment the number using said number in the control ID. You can keep a variable somewhere, client-side or server-side, or you can count the number of existing elements and increment.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
hi
the second parameter suppose to:
Indicates whether execution of the current page should terminate.
but what does this mean ??
where i have to realty use the second parameter ??
thank you
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Tamimi - Code wrote: Indicates whether execution of the current page should terminate.
When we use Response.Redirect , it tries to end the current request and start a new request.The second parameter is endResponse , when it is set to true , it calls Response.End method, which throws an exception when it gets completed. This is bydefault behaviour of this method.This method is provided only for compatibility with ASP.
So it is recommended to set it false, to avoid the exception because it is not good for the website performance.
If you still want to set it true . Then you should firts call CompleteRequest() method. It will avoid calling end method.
|
|
|
|
|
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
I want people to download files, EXE & DOCs from my website but I want to track the download, therefore I don't want them to now the real url so they won't be able to go there directly to download
how can I do hat?
|
|
|
|
|
You can show some link on your website's page. That link should be your website's page (say Download Page). There on pageload, you can write the code for your tracking purpose. Then after you can redirect the user to download link directly.
So user will not able to the download url directly, it will be your pgae link.
One more thing you can do.If you want that user should enter some information before downloading on the download page, after click the link on your page, show a form to user, there after making the entries user should click on a button (say 'Authenticate and Download') then first authenticate the user and after this redirect to the download link.
|
|
|
|
|
Instead of having <asp:hyperlink> or a <a href="" /> with the download file's path, have a <asp:linkbutton>. In the OnClick event of the <asp:linkbutton> first update the table that tracks the number of times this file was downloaded, and then do a Response.Redirect(...) with the executable's file name.
In this case (using LinkButton), you should be generating those links dynamically, say in a GridView so that you could identify the file to be downloaded, else if it's just 1/ 2 downloads you could probably use the LinkButton's Text to identify the file to be downloaded. In this way you will be able to track the number of downloads and the user won't be able to identify the link. A View Source also just shows a __doPostBack for the LinkButton's.
Hope this helps...
Cheers,
Karthik
modified on Saturday, October 9, 2010 6:34 PM
|
|
|
|
|
how can I view external websites on my website in a panel or something similar to the browser control on WinForm?
|
|
|
|
|
there is this jQuery script called mootools.
|
|
|
|