|
Hi
Sorry for not being clear. I do want postback to be called, however at the moment I explicitly call btnSubmit_Click in my postback so that it would fire the event.
I feel this is becoming more of a javascript issue now and that this is the wrong place for it but how do I make it so that it just postsback rather than use submit()
Sorry for the wrong message board.
Cheers
Dan
|
|
|
|
|
Is btnSubmit_Click a server-side or client-side method? If it's server-side then you should be able to register it with the click event by setting the name of the method to the value of the "Click" property in the property window or as the OnClick attribute of the asp:Button element.
Also, have you verified that you've added runat="server" to the control? I sometimes forget this when hand-coding controls.
If neither of these helps, could you provide some code snippets of your web form code?
|
|
|
|
|
Thanks for all the help guys
Turns out it wasnt an ASP problem but my lack of understanding of javascript.
Just incase any one else has the problem i had i fixed it by:
adding to the form tag onsubmit="return ValidateFields();" this runs the client side code and then if returns true posts back with the inforation of which server control event needs firing.
Thanks again
Dan
|
|
|
|
|
hi all
here i have a problem with crystal reports. while printing a report, print is coming in two pages.
if i have grouping on any one field, it is ginving an error- 'crystal engine error'
what is best way to use the crystal reports.
thanking you
|
|
|
|
|
Hi all. While developing the application in asp.net 2.0, i have seen once a file (auto generated by a tool in which all namespaces, sources , dataset references etc etc can be found) when i was in debug mode. But I want to see it without debug mode. Can anyone tell me from where i can see that file. Please tell me. i will be very thankful to you.
|
|
|
|
|
Normally, the ASP.NET generates the dynamic source file in the ASP.NET temp folder, however when the debug attribute of the comilation entry is false, it does not generate the source files such as .cs, or .vb there. You might be interested in Dino's article[^].
|
|
|
|
|
I am using Visual Web Developer 2005 and am using the provided login controls to control access to a site. How can I access the logged in user's name (or role membership) in VB without putting one of the login controls on the page?
|
|
|
|
|
Bah! I found it.
FYI, it's in Page.User.Identity.Name.
|
|
|
|
|
Hi,
I wish to submit my web form by hitting the ENTER Key from anywhere in the form.
How to achieve this? Kindly help me
I am using asp.net 1.1
Regards,
Jay
|
|
|
|
|
If you have a Submit button, this will be "pressed" automatically.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
There is a subtle "feature" in IE that can cause problems. If, for example, your form consists of only one textbox and one or more buttons, then when the textbox has the focus and you hit ENTER, the form will still do a postback, but the button's click event handler does not get raised.
You can work around this in one of two ways:
1) Insert another textbox in the form, but use CSS to hide it from view.
2) Handle the "ENTER" keypress in JavaScript and use it to manually invoke a postback from the submit button.
I know this doesn't directly answer your question, but I thought I'd throw it out there in the off chance that it would help you out.
|
|
|
|
|
put ur all controls into a Pannel and set the Pannel DefaultButton=urButtonName
hope tht will help u.
Deepak
Smile a Lots,Its Costs Nothing
|
|
|
|
|
Hi I have a website I am developing and wish for it to be valid XHTML.
I have no trouble validating the .htm pages and so can proudly display the W3Schools validated loge, however is there a way to go about validating the .aspx pages so they too can share the pride of the .htm pages?
Thanks for any help
Dan
|
|
|
|
|
Use the W3 Validator[^] against the pages. If your site is developed against .NET 2 you can also use Visual Studio 2005 to validate it.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello friends
Ok, so I was tasked to build this little ‘window’ (I’m speaking enduser to dynamically add/delete rows containing two values: Role and Deployable. So I thought GridView of course. Also I figured the best way to do this is to create a dataset and store it as session variable, and dynamically bind that sucker to my GridView… below is my ‘example’ code:
********Asp net Page*******
<form id="form1" runat="server">
<asp:DropDownList ID="roleDropDownList" runat="server" TabIndex="1">
<asp:ListItem>Doctor</asp:ListItem>
<asp:ListItem>Nurse</asp:ListItem>
<asp:ListItem>Engineer</asp:ListItem>
<asp:ListItem>Teacher</asp:ListItem>
<asp:ListItem>Clerk</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DepDropDownList" runat="server" TabIndex="2">
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="addButton" runat="server" OnClick="addButton_Click" Text="Add Role" TabIndex="3" /><br />
<asp:GridView ID="GridView2" runat="server" ShowFooter="True" OnRowDeleting="GridView2_RowDeleting" Width="400px" EmptyDataText="Currently there are no roles entered in this area..." TabIndex="4">
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1"
CommandName="Delete" runat="server">
Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</form>
*******Code Behind******
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
public partial class TEST_testingGridView : System.Web.UI.Page
{
DataSet ds;
DataTable dt;
DataRow dr;
StringBuilder sb;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["smeRoles"] != null)
{
GridView2.DataSource = (DataSet)(Session["smeRoles"]);
GridView2.DataBind();
}
}
protected void addButton_Click(object sender, EventArgs e)
{
if (Session["smeRoles"] != null)
{
ds = (DataSet)(Session["smeRoles"]);
dt = ds.Tables["Roles"];
int rows = ds.Tables["Roles"].Rows.Count;
DataRow dr1 = dt.NewRow();
dr1["Role"] = roleDropDownList.SelectedValue;
dr1["Deployable"] = DepDropDownList.SelectedValue;
ds.Tables["Roles"].Rows.Add(dr1);
GridView2.DataSource = ds.Tables["Roles"];
GridView2.DataBind();
Session["smeRoles"] = ds;
dt.Dispose();
ds.Dispose();
}
else
{
ds = new DataSet();
DataTable dt = new DataTable("Roles");
DataColumn dc1 = new DataColumn("Role", typeof(string));
DataColumn dc2 = new DataColumn("Deployable", typeof(string));
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
DataRow dr1 = dt.NewRow();
dr1["Role"] = roleDropDownList.SelectedValue;
dr1["Deployable"] = DepDropDownList.SelectedValue;
dt.Rows.Add(dr1);
ds.Tables.Add(dt);
GridView2.DataSource = ds.Tables["Roles"];
GridView2.DataBind();
Session["smeRoles"] = ds;
dt.Dispose();
ds.Dispose();
}
generateOutput(); //for testing
}
protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int deleteIndex = e.RowIndex;
ds = (DataSet)(Session["smeRoles"]);
ds.Tables["Roles"].Rows[deleteIndex].Delete();
Session["smeRoles"] = ds;
GridView2.DataSource = ds;
GridView2.DataBind();
ds.Dispose();
generateOutput(); //for testing
}
/// <summary>
/// For testing...
/// </summary>
private void generateOutput()
{
sb = new StringBuilder();
for (int i = 0; i < GridView2.Rows.Count; i++)
{
sb.Append(GridView2.Rows[i].Cells[1].Text + ", " + GridView2.Rows[i].Cells[2].Text + "\n");
}
Response.Write(sb.ToString());
sb.Remove(0, sb.Length);
}
}
Everything works ok, except that the event handler for the addRoles button fires everytime I refresh the page!!! However, if I trigger the event handler wired to the delete LinkButton within the GridView (or any other event handler for that matter) and then refresh the page I do not have this problem. Can anyone tell me what’s going on?!? Am I missing something? I must be, because this is the first time I have seen such thing!
Many thanks in advance.
Nila
|
|
|
|
|
First thing I'd do is put IsPostback in the Page_Load event. Don't bind based on the session.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I'm going to guess that the event handler for the addRoles button (or is it addButton Button?) fires when you refresh the page only if you press the button before refreshing the page (meaning on the previous page view, the button was pressed).
If this is correct: This is a common problem for page developers. When you hit refresh, the posted data is posted back; that posted data contained information telling the page to execute the button's event handler so when you hit refresh the event will be fired again.
There are several ways to overcome this, the simplest being to check the datasource to see if the data being inserted is already in the datasource, if not insert it, if so don't insert it.
|
|
|
|
|
Thanks Paszat
Although, I have to say, when I trigger some other event handler and then refresh the page data persists. But anyways- I will give your solution a try. Thanks again.
Nila
|
|
|
|
|
Hi,
I feel you are Missing some thing else. By Default any Event will not fire unless it is called implicitly. Here i want some info from you whether you debugged this with break points if so which event is called first?.
|
|
|
|
|
Nagendra,
Thanks for the debug tip. After stepping into the code, I saw that the button click event fires again when I refresh the page... very frustrating!! So to remedy it as quickly as possible, I created a small method that would check to see if the button click event would 'quilify' to be fired given user's input.
I just don't have the time to investigate this silliness- need to keep the boss happy
Thanks again!
Nila
|
|
|
|
|
Hai,
That is a Good Method of Making your self Comfortable in Office.
But you try it later and you can come across some good concepts in that area.
and if possible send me that page complete as an attachment to nagendrarao@glowtouch.com.
|
|
|
|
|
It's not about making myself comfortable; Im just trying to remedy this and move on- there is lots of pressure when you develop for an emergency operations type group.
And I agree with you on finding out exactly WHY sometimes things behave the way they do But now is not the time for that, maybe later. Let me do a couple of things, and then I will send you the code.
Thanks again!
Nila
|
|
|
|
|
just put and change according to ur need following code into
public partial class<br />
{<br />
private bool _refreshState;
private bool _isRefresh;
<br />
public bool IsRefresh
{<br />
get <br />
{<br />
return _isRefresh;
}<br />
}<br />
protected override object SaveViewState()<br />
{<br />
Session["_ISREFRESH"] = _refreshState;
object[] allstates = new object[2];
allstates[0] = base.SaveViewState();
allstates[1] = !_refreshState;
return allstates;<br />
}<br />
protected override void LoadViewState(object savedState)
{<br />
try<br />
{<br />
object[] allstates = (object[])savedState;
base.LoadViewState(allstates[0]);
_refreshState = (bool)allstates[1];<br />
_isRefresh = _refreshState == (bool)Session["_ISREFRESH"];<br />
}<br />
catch (Exception e)<br />
{<br />
}<br />
}<br />
}
and which event is called thru Refresh just put flowwowing code into
if (_isRefresh == false)<br />
{<br />
<br />
your code for event is here<br />
<br />
}
hope tht'll helps u
Deepak
Smile a Lots,Its Costs Nothing
|
|
|
|
|
Thanks Deepak!
There has got to be a bug in this, because the button click event fires all on its own when I refresh the page... so I finally decided to create a small private method that checks to see whether or not events in the button click would 'quilify' to be executed - very similar to your approach. Thanks again, don't know what I would do without all you guys' help and support!!!!
Nila
|
|
|
|
|
Dear All
i am bit new to dotnet. currently making web application using asp.net and C#(VS2005). i have dropdownlist control(Autopostback is true) on its selected index code
i have wrote dropdownlist_selectedindex as follows its works fine whenever there is more than one record(by fine i mean in debug mode, control flow through it ) but for singal record
controls does not go through it. What is a problem. Please guide me.
thanks
protected void DropDownListinquiryid_SelectedIndexChanged(object sender, EventArgs e)
{
setting = ConfigurationManager.ConnectionStrings["databaseconnection"];
if (setting != null)
{
conn = new SqlConnection(setting.ConnectionString);
conn.Open();
query = "select max(inquiryid) from followupdtl where inquiryid='"+DropDownListinquiryid.SelectedItem.Text+"'";
cmd = new SqlCommand(query, conn);
if (cmd.ExecuteScalar().ToString().Equals(""))
{
txtmaxno.Text = "01";
}
else
{
int number = int.Parse(cmd.ExecuteScalar().ToString());
number++;
if (number.ToString().Length == 1)
{
txtmaxno.Text = number.ToString("0#");
}
else
{
txtmaxno.Text = number.ToString("##");
}
}
}
}
regards
imran khan
|
|
|
|