|
Mostly likely we are not being told the complete story by the OP
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You have told the form in page1 that it should always post back to Default.aspx, so when you call the submit function the page posts back to Default. If you want to navigate to Default on post back, get rid of the action="Default.aspx" or change it to page1.aspx, and put a
Response.Redirict("Default.aspx"); in the page load or some other event handler.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
The documentation on IsPostBack is not very good.
Gets a value that indicates whether the page is being rendered for the first time or is being loaded in response to a postback.
That definition assumes that the only way you are going to get to a page for the first time is through an HTTP GET. The reason being that in ASP.Net they expect pages to post back only to themselves not to other pages.
So the problem you are running into is that the page is both being rendered in response to a postback (from a different page) AND it is the first visit to the page.
|
|
|
|
|
Hi all,
I have few doubts running though my mind which I want to clear. Here is my scenario
let's say I want to create a website for library management.
I need to have registration page where I will allow users to register and login.
My doubt is : After login how do I restrict users from accessing only the authorized page ? also I need to make sure that they should not access pages by entering the url directly without authentication ? i don't want to use the login controls provided in asp.net by default.
Thanks
|
|
|
|
|
Forms Authentication
I think this should cover what you want, it essentially provides an authentication model for you that doesn't have to use .NET login controls, you can use the API to come up with one yourself.
|
|
|
|
|
thanks.. I will look into it.. any other techniques ?
|
|
|
|
|
Dear friends,
I have a linkbutton in gridview. When I click on that linkbutton, I need to get some data based on the row which I clicked and this data to be sent to a javascript function. Please help me how to achieve this. It's very urgent.
Regards,
Cheguri.
|
|
|
|
|
For that you need to use "ItemTemplate" column for your Link Button and write according to following code.
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnCustomerExist"
text="customer exist"
Runat=Server
OnClick="CustomerAlreadyExist"
OnClientClick="return confirmSubmit()"
Width="100″ />
</ItemTemplate>
</asp:TemplateField>
You just need to use LinkButton instead of button.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
This isn't going to help with calling a funciton dependent upon the underlying data row....
Assuming you want to create a specific Javascript call for each row, dependent on (say) the row ID of the underlying dataview, you would do better to use a ButtonColumn:
<asp:ButtonColumn ButtonType="LinkButton" CommandName="doesnt_matter" Text="whatever" />
and add your JavaScript fucntion in the page's head:
function fname(r) {
alert('You clicked row with ID# ' + r);
}
and bind this in the ItemDataBound event:
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim dr As DataRow = e.Item.DataItem.Row
Dim js As String
Dim btn As LinkButton = e.Item.Cells(X).Controls(0) ' replace "X" by the appropriate column index
js = "fname(" & CStr(dr("ID")) & ")"; return false;"
btn.Attributes.Add("onclick", js)
End If
NB the extra "return false" statement - this prevents the link-button from posting the entire form back to the server.
btw, OP: re "It's very urgent."
Please don't put this sort of thing in your posts. That is no-one's problem but yours.
|
|
|
|
|
here is my page scenerio.
On page load, i have a web form and a gridview. The gridview displays the xsaction details of the logged in user, (this works gr8)
When I enter details in the web form and click Add. the record should update in the gridview.(this is perfect)
When I click Edit in a row (in the gridview), the row details should populate in the web form (this is also correct)
After I make changes in the web form and click Update, the changes should be updated in the gridview.
(this gives the problem)
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.Data.SqlClient;
using Logic;
public partial class Portfolio : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
Includes obj = new Includes();
string str2 = "select A.SCHEME_NAME ,B.SCHEME_NAV ,B.SCHEME_UNITS ,B.AMT_INVESTED ,B.FOLIO_ID FROM NAV A,PORTFOLIO_MASTER B WHERE B.USER_ID='" + Session["user_id"] + "' and b.scheme_id =a.scheme_code";
DataSet ds1 = obj.getDataSet(str2);
GridView1.DataSource = ds1;
GridView1.DataBind();
}
if (Request.QueryString["scheme_name"]!=null)
{
Response.Write(Request.QueryString["scheme_name"]);
Button2.Visible = true;
Button1.Visible = false;
Includes obj4 = new Includes();
string sch_name = Request.QueryString["scheme_name"].ToString();
string str="select scheme_code,scheme_name from nav where scheme_name ="+sch_name +"";
DataSet ds6 = obj4.getDataSet(str);
DataRow dr = ds6.Tables[0].Rows[0];
txt_schname.Text= dr["scheme_name"].ToString();
string s_id=dr["scheme_code"].ToString();
string str1 = "select scheme_nav,scheme_units,amt_invested,folio_id,purchase_date from portfolio_master where scheme_id=" + s_id;
DataSet ds8 = obj4.getDataSet(str1);
DataRow dr1 = ds8.Tables[0].Rows[0];
scheme_nav.Text = dr1["scheme_nav"].ToString();
txt_units.Text = dr1["scheme_units"].ToString();
txt_amt.Text = dr1["amt_invested"].ToString();
txt_folio.Text = dr1["folio_id"].ToString();
txt_purchasedate.Text = dr1["purchase_date"].ToString();
}
if (Session["user_id"] == "")
{
Response.Write(Session["user_id"]);
Response.Redirect("home.aspx");
Session["exp"] = "y";
}
else
{
this.txt_purchasedate.DataBind();
this.ImageButton1.Attributes.Add("onclick", "openPopUp('Cd.aspx')");
txt_amt.Attributes.Add("onkeypress", "return OnlyNums(event,this.value);");
}
}
protected void Page_LoadComplete(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Includes obj3 = new Includes();
float nav = Convert.ToSingle(scheme_nav.Text);
float units = Convert.ToSingle(txt_units.Text);
float amt = Convert.ToSingle(txt_amt.Text);
string folio=txt_folio.Text.Trim();
string remarks = txt_remarks.Text.ToString().Trim();
string po_date = txt_purchasedate.Text.ToString().Trim();
DateTime dt;
dt = Convert.ToDateTime(po_date);
string sc_name = txt_schname.Text .ToString().Trim ();
string str = "select scheme_code,scheme_name from nav where scheme_name='" + sc_name + "' ";
DataSet ds = obj3.getDataSet(str);
DataTable dt1 = ds.Tables[0];
int cnt = dt1.Rows.Count;
string sch_code = "";
for(int i=0;i<cnt;i++)
{
sch_code = dt1.Rows[i]["scheme_code"].ToString().Trim();
}
DateTime dt2 = DateTime.Now;
DateTime dd=new DateTime ();
string s = dt2.ToShortDateString();
dd = Convert.ToDateTime(s);
string str1="insert into portfolio_master values ('"+Session["user_id"]+"','"+sch_code+"',"+nav +","+units +","+amt +",'"+dt +"','"+folio+"','"+remarks +"','" + dd +"')";
obj3.executeQuery(str1);
this.Server.Transfer("portfolio.aspx?update=y");
GridView1.DataBind();
}
protected void ImageButton2_Click2(object sender, ImageClickEventArgs e)
{
Calendar1.Visible = true;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
txt_purchasedate.Text = Calendar1.SelectedDate.ToString();
Calendar1.Visible = false;
}
protected void ImageButton2_Click3(object sender, ImageClickEventArgs e)
{
Calendar1.Visible = true;
}
protected void Edit(object sender, GridViewEditEventArgs e)
{
Includes obj = new Includes();
object obj14 = GridView1.Rows[e.NewEditIndex].Cells[0].Text;
Response.Redirect("portfolio.aspx?scheme_name='" + obj14+"'");
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Write(Request.QueryString["scheme_name"]);
Response.Write(Session["user_id"]);
Includes obj22 = new Includes();
string sname = txt_schname.Text.ToString().Trim();
float nav1 = Convert.ToSingle(scheme_nav.Text);
float amt = Convert.ToSingle(txt_amt.Text);
float units = Convert.ToSingle(txt_units.Text);
DateTime dt5;
dt5 = Convert.ToDateTime(txt_purchasedate.Text);
string str4 = "update portfolio_master set scheme_nav= " + nav1 + " where scheme_id in(select scheme_code from nav where scheme_name='" + sname + "')";
obj22.executeQuery(str4);
TextBox1.Text = str4;
GridView1.DataBind();
Button2.Visible = false;
Button1.Visible = true;
Response.Redirect("portfolio.aspx");
}
protected void scheme_nav_TextChanged(object sender, EventArgs e)
{
string ss = scheme_nav.Text.Trim();
Response.Write(ss);
}
}
|
|
|
|
|
You need to Bind Grid once again after database update. Otherwise how Grid comes to know that database is updated and it should show latest data . You need to force it. TO avoid useless postback, try using AJAX.
|
|
|
|
|
_______________________ wrote: this.Server.Transfer("portfolio.aspx?update=y"); GridView1.DataBind();
This is Jumping to portfolio.aspx with IsPostBack = True, So GridView1.DataBind(); below it is never executed. You need to run query once again friend to bring back latest data.
|
|
|
|
|
Hi All,
There is two column in Gridview. First is checkbox and second is textbox.
when i checkbox is check, then textbox visible should be false.
else i have to make textbox visible true.
got it...
if checkbox.checked= true then
textbox.Visible= false
else
textbox.Visible= true
end if
so...problem is i am not getting the event of checkbox...
plz can u send me code..
|
|
|
|
|
DataGridDemo[^] Look at the section titled Checkboxes and Textboxes
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks for your replay...
|
|
|
|
|
if u want disable the textbox which is in grid acco. to checkbox then you should write this code
for i=0 to gridview.row.count-1
if ctype(gridview.rows(i).findcontrol("checkbox"),checkbox).checked=true then
ctype(gridview.rows(i).findcontrol("textbox"),visible).checked=false
else
ctype(gridview.rows(i).findcontrol("textbox"),visible).checked=false
end if
next
|
|
|
|
|
|
|
hi all,
can u give me the solution of crystal reports...
on live crystal reports images not display.......
thanx in advance
|
|
|
|
|
vid nandha wrote: can u give me the solution of crystal reports...
You need to elaborate on what you need!
Meanwhile, have a look at this if it helps: Dynamic Crystal Report with C#[^]
|
|
|
|
|
Hi
I have been stuck withl this problem for sometime now. I want to programatically add recurring event to my google calendar. But i'm not able to get correct format for the recurring rule string. I'm able to add a non-recurring event, but when i set recurring rule to a event an try to insert this event, i get
"(400)Bad Request" error. Can somebody share a working example of using Recurrence Rule to add event to google calendar.
My example code and forum discussion can also be found at :
http://www.google.com/support/forum/p/apps-apis/thread?tid=6dcb9f5db13727ed&hl=en
Please help. do not just point me to http://tools.ietf.org/html/rfc2445 or a similar doc.
I want to know a working format for RRULE for Yearly or Monthly ocurring events.
Thanx,
s.a.w.
|
|
|
|
|
I have an embedded css resource which contains styling info for a table. When I run my app, the table is shown with the styles specified. During design time, these styles are not applied to my table. More info below. I think my problem may be that the OnPreRender may not be run during design time. What are my options?
Thanks in advance.
assembly.cs:
[assembly: WebResource("MyNamespace.StyleSheet.css", "text/css", PerformSubstitution=true)]
MyControl.cs:
void RegisterStyleSheet()
{
string includeTemplate =
"<link rel='stylesheet' text='text/css' href='{0}' />";
string includeLocation =
Page.ClientScript.GetWebResourceUrl(this.GetType(), "MyNamespace.StyleSheet.css");
LiteralControl include =
new LiteralControl(String.Format(includeTemplate, includeLocation));
((System.Web.UI.HtmlControls.HtmlHead)Page.Header).Controls.Add(include);
}
protected override void OnPreRender(EventArgs e)
{
RegisterStyleSheet();
base.OnPreRender(e);
}
modified on Friday, July 9, 2010 1:54 PM
|
|
|
|
|
Figured it out. I changd the RegisterStyleSheet to return a string:
string RegisterStyleSheet()
{
string includeTemplate =
"<link rel='stylesheet' text='text/css' href='{0}' />";
string includeLocation =
Page.ClientScript.GetWebResourceUrl(this.GetType(), "Fyuzon.Membership.Web.Css.BaseGridStyleSheet.css");
return String.Format(includeTemplate, includeLocation);
}
and override the RenderControl with the following:
public override void RenderControl(HtmlTextWriter writer)
{
writer.Write(this.RegisterStyleSheet());
base.RenderControl(writer);
}
Works like a charm... If there is a better way of doing this, please do let me know.
|
|
|
|
|
Hi,
I needed to create some controls in itemdatabound(grid) coz the number of controls to be rendered was only known at item databound of grid. the controls needed to raise event so i added events at runtime. All was working fine until recently i was asked to have another view for those controls outside the grid. I managed to create the controls once again in pageload. but the treeview was having viewstate problems coz controls once loaded and then if changed , the viewstate for the previous controls was being assigned to current controls. I managed to solve this by disabling viewstate for all the controls but now i see that the checkbox checkedchanged event is raised only when it is checked.
The reason being that on pageload , since the checkbox has no viewstate, so the default value being unchecked is considered changed only if checkbox is checked.
The problem gets solved when i enable viewsate but i can't enable viewstate.
Is there any work around for this issue... . can the viewstate be assigned values for a particular checkbox and then removed at a button click, because there is a save button and if i can clear viewstate values at click of that button then probably it would work. I have tried clearviewstate and its not working.
Please provide help
Thanks
haseeb
|
|
|
|
|
So the problem is with a treeview? I can't tell from your question if the gridview is relevant or even on the same page. Are you changing the viewstate setting at the control level or the page level? I am not sure what "previous controls" you are talking about either. I think your best approach is to solve the viewstate problems the treeview was having before you turned off viewstate. You should never be forced to turn off viewstate to get something to work.
The gridview should provide a naming container to prevent name collisions between the two sets of controls, but maybe you are adding them in some weird way.
|
|
|
|