|
I’m having and issue firing code behind on one of my asp buttons.
Screen Shot 1 - http://beta.sdsna.com/ModalFiles/ss1.jpg - Prior to clicking the update button
Screen Shot 2 - http://beta.sdsna.com/ModalFiles/ss2.jpg - Box after clicking the update button, no event behind was fired
Project Files - http://beta.sdsna.com/ModalFiles/AJAXModalPopup.zip
Project Overview:
I have one list page (UserList.aspx) that contains a ModalPopupExtender. An ascx control (ModalContainer.ascx) loads within that ModalPopupExtender and retrieves a few parameters set by the list page. Based on one of the parameters, the ModalContainer.ascx control dynamically loads in another ascx control. The control that gets loaded in could be to edit user, add user, etc.
Everything works fine except on the last ascx control that gets loaded in. On that control I have an asp submit button which should fire code behind but does not.
UserList.aspx
UserList.aspx contains an add user button which calls a JavaScript function ShowModalPopup and accepts up to 4 parameters. When this function is called it sets global JavaScript variables of the passed parameters and then opens up the ModalPopupExtender which has the ModalContainer.ascx control inside.
ModalContainer.ascx
When the popup extender is opened the ascx control has a JavaScript function for pageLoad(). The pageLoad() function does $find(“ModalPopupExtender”).add_shown(SetPostBack);.
The SetPostBack() function does the following – gets the global JavaScript variables and inserts the values into hidden text box fields and then fires btnPostBack.click(); which is a hidden button on the form.
I have an update panel with the ContentTemplate having an ASP:Placeholder and the Trigger being btnPostBack with EventName=”Click”.
So when this button is clicked, the code behind reads the values in the hidden text boxes and loads into the ASP:Placeholder the proper ascx control – it being UserEdit.ascx for this example.
UserEdit.ascx
This control contains 3 ASP:Textboxes, UpdatePanel and ASP:RequiredFieldValidators. In the code behind page load event I again read the values in the hidden text boxes and populate the form from the database.
The purpose of the update panel is when the user clicks the update button, I validate that the username is not already taken and if it is I show a message label that is in the ContentTemplate of the update panel.
All of the above works fine except when I click the update button. On clicking of the update button it does not fire the Click event in the code behind. Instead it basically closes itself and what I am left with is a blank modal popup.
The RequiredFieldValidators do work - just the code behind event does not. Removing the validators does not fix the problem either..
Any idea’s or how I should approach this in a different manner to accomplish my goal?
ModalContainer.ascx - CODE <br />
<br />
<!-- Post Back Javascript Code Start --><br />
<script language="javascript"><br />
function pageLoad(){<br />
$find("ModalContainerPopupBehavior").add_shown(SetPostBack);
}<br />
<br />
function SetPostBack(){ <br />
var objParam1TextBox = '<%=txtParam1.ClientID %>';<br />
document.getElementById(objParam1TextBox).value=vParam1;<br />
<br />
var objParam2TextBox = '<%=txtParam2.ClientID %>';<br />
document.getElementById(objParam2TextBox).value=vParam2;<br />
<br />
var objParam3TextBox = '<%=txtParam3.ClientID %>';<br />
document.getElementById(objParam3TextBox).value=vParam3; <br />
<br />
var objParam4TextBox = '<%=txtParam4.ClientID %>';<br />
document.getElementById(objParam4TextBox).value=vParam3; <br />
<br />
var objControl = '<%=btnPostBack.ClientID %>';<br />
document.getElementById(objControl).click(); <br />
} <br />
<br />
</script><br />
<!-- Post Back Javascript Code End --><br />
<br />
<!-- Hidden Text Boxes to Pass Values from Calling Form --><br />
<asp:TextBox ID="txtParam1" runat="server" style="display:none;"></asp:TextBox><br />
<asp:TextBox ID="txtParam2" runat="server" style="display:none;"></asp:TextBox><br />
<asp:TextBox ID="txtParam3" runat="server" style="display:none;"></asp:TextBox> <br />
<asp:TextBox ID="txtParam4" runat="server" style="display:none;"></asp:TextBox> <br />
<br />
<!-- Hidden Postback button used to post back form on load to set Hidden Text Box Values --><br />
<asp:Button ID="btnPostBack" runat="Server" Text="Post Back" style="display:none;" CausesValidation="false" /> <br />
<br />
<asp:UpdatePanel ID="updPostBack" runat="server"> <br />
<ContentTemplate><br />
<asp:PlaceHolder ID="phModal" runat="server"></asp:PlaceHolder><br />
</ContentTemplate><br />
<Triggers> <br />
<asp:AsyncPostBackTrigger ControlID="btnPostBack" EventName="Click" /><br />
</Triggers><br />
</asp:UpdatePanel> <br />
<br />
<br />
<br />
UserEdit.ascx CODE BELOW<br />
<br />
<table cellpadding="0" cellspacing="4" border="0"><br />
<tr><br />
<td colspan="2">User Edit</td><br />
</tr> <br />
<tr><br />
<td>First:</td><br />
<td><asp:TextBox ID="txtFirstName" runat="server" CssClass="input" MaxLength="50"></asp:TextBox></td><br />
</tr><br />
<tr><br />
<td>Last:</td><br />
<td><asp:TextBox ID="txtLastName" runat="Server" CssClass="input" MaxLength="50"></asp:TextBox></td><br />
</tr><br />
<tr><br />
<td>User:</td><br />
<td><asp:TextBox ID="txtUserName" runat="server" CssClass="input" MaxLength="50"></asp:TextBox></td><br />
</tr><br />
<tr><br />
<td colspan="2" align="right"> <br />
<input type="button" value="Cancel" onclick="CloseModalPopup('ModalContainerPopupBehavior');" /><asp:Button ID="btnUpdateUser" runat="server" Text="Update User" CssClass="formButton" /> <br />
</td><br />
</tr> <br />
</table> <br />
<br />
<asp:UpdatePanel ID="updSubmit" runat="server"><br />
<ContentTemplate> <br />
<asp:Label ID="lblMessage" runat="Server"></asp:Label><br />
</ContentTemplate><br />
<Triggers><br />
<asp:AsyncPostBackTrigger ControlID="btnUpdateUser" EventName="Click" /> <br />
</Triggers> <br />
</asp:UpdatePanel> <br />
<br />
<!-- Validation Controls --><br />
<asp:RequiredFieldValidator runat="server" ID="vFirstName" ControlToValidate="txtFirstName" SetFocusOnError="true" Display="None" ErrorMessage="<b>Required Field Missing</b><br />First name is required." /><br />
<ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="veFirstName" TargetControlID="vFirstName" /> <br />
<br />
<asp:RequiredFieldValidator runat="server" ID="vLastName" ControlToValidate="txtLastName" SetFocusOnError="true" Display="None" ErrorMessage="<b>Required Field Missing</b><br />Last name is required." /><br />
<ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="veLastName" TargetControlID="vLastName" /> <br />
<br />
<asp:RequiredFieldValidator runat="server" ID="vUserName" ControlToValidate="txtUserName" SetFocusOnError="true" Display="None" ErrorMessage="<b>Required Field Missing</b><br />User name is required." /><br />
<ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="veUserName" TargetControlID="vUserName" />
modified on Tuesday, September 2, 2008 6:54 PM
|
|
|
|
|
I am accessing a FORTRAN dll into ASP.Net 2005. The dll is taking input from a .dat file after processing it generates another .dat as an output. Here's ASP.Net is working as an interface of Input(by which user can supply input file) and Output(by which user can see the output in various listbox, textbox,etc).
I used importdll atrribute to declate DLL, and used call keyword to call the function of DLL. The program is working fine when i am executing using .NET IDE. but when i published the application it doesn't work. ASP.Net Application stops IIS on function call of FORTRAN dll.
Regards
Manoj Shukla
|
|
|
|
|
hi,
Can any body please help me? When I am opening the asp.net configuration it giving me this error as follows.
Provider Management
Could not establish a connection to the database. If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider.
What I need to do to connect to sql server. I have already installed sql still its showing me this error.
|
|
|
|
|
pinkidasu wrote: When I am opening the asp.net configuration it giving me this error as follows.
Which Configuration File are you opening ?
pinkidasu wrote: What I need to do to connect to sql server. I have already installed sql still its showing me this error.
I think you are trying to do any personalization or membership kind of operation.
Do one thing
From VS Command Prompt - > Run aspnet_regsql Command
This it will as for the data base and give the database server name . It will create some personalization table and procedure on your database.
Hope then your problem will be resolved !!!
Thanks
|
|
|
|
|
you need to add membership configuration to web.config. Take a look at this article:
Membership[^]
|
|
|
|
|
Hi guys i have a issue. I use Mailattachment to send my attachment how ever if my attachment size is too huge. The sending fail. Is there a way to fix or increase the size of my attachment size for attachment.
KaKaShi HaTaKe
|
|
|
|
|
This is because of the fact that Mail Server sets the maximum size to send/accept the attachment.
If its over its limit, it fails...
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
bro are u saying is the SMTP? but i can't even upload the file when i submit and it didn't even go into the breakpoint at all.
KaKaShi HaTaKe
|
|
|
|
|
Im developing a small ftp function in my program, but im getting a runtime error message on running this part of the code:
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(FTPAddress + "/" + Path.GetFileName(filePath));
error message:
Unable to cast object of type 'System.Net.HttpWebRequest' to type 'System.Net.FtpWebRequest'.
more info:
FTPAddress has a value of http://server.co.za
the whole function is bellow
private void uploadFile(string FTPAddress, string filePath, string username, string password)
{
//Create FTP request
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(FTPAddress + "/" + Path.GetFileName(filePath));
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(username, password);
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false;
//Load the file
FileStream stream = File.OpenRead(filePath);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
stream.Close();
//Upload file
Stream reqStream = request.GetRequestStream();
reqStream.Write(buffer, 0, buffer.Length);
reqStream.Close();
MessageBox.Show("Uploaded Successfully");
}
does anyone know what's causing this
|
|
|
|
|
hi all
im doin the application to upload and retrieve the images from database to datagrid ...im saving the images in binary format ..im getting large images in the datagris ..how to display the small images in the image column in datagrid...
plz help me
muppala
|
|
|
|
|
You need to make thumbnails.
Sure if you google it you'll find a simple tut.
|
|
|
|
|
Change Resolution...
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
hi
my appliocation is to upload and retrieve the images from database to datagrid.In that datagrid i ve image ID hyperlink coloumn.If that hyperlink is clicked the querystring which will passed to the URL should be encrypted (image ID must be in encrypted form ).I have in many ways but im not getting...please help me..
how can i get the querystring passed to the url in encrption form to the other page when i click the hyperlink column in the datagrid ..plz help regarding this problem...
muppala
|
|
|
|
|
How about using a session variable instead? Then you need not worry about the query string at all.
Search results[^] for "session variables"
But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson Because programming is an art, not a science. Marc Clifton I gave up when I couldn't spell "egg". Justine Allen
|
|
|
|
|
hi all.... i m developing a application in which i m displaying data from database to the gridview. In the gridview there r checkboxes in the first column for every row.now i want that after selecting some rows(checking chk boxes) wen i press ok button, in database a id should generate for these rows and the id should be same for all these selected rows.
thanks in advance....
|
|
|
|
|
Walkthrough for your problem.
1.Open visual studio 2005.
Bad idea, I am lazy
Check this article[^]
|
|
|
|
|
hi palli, that is right i have done this finding the checked checkboxes in gridview but after finding checkboxes how to generate same id for the selected rows,i have no idea about that............can u give some idea and sample codes. it will be a greate help..............
|
|
|
|
|
I have created a web application in asp.net. But after building my application I do not get bin folder and global.aspx file.
What will be problem.
Thank in advance!
|
|
|
|
|
I am having the same trouble.
I tried to add the bin folder forcefully , but the dlls still did not get created.
cana nybody suggestghg
|
|
|
|
|
Hello friends
I am getting a problem with update pannel
I have placed a drop down list in the update pannel for which i am assigning datasource in the page load event i have checked the ispostback property of the page and placed it inside
i have also placed few text boxes there
i am having a save button whenever i click on it the selected index of the dropdown list becomes zero
please tell me how to stop it becoming zero ..
Thanks and regards
If You win You need not Explain............
But If You Loose You Should not be there to Explain......
|
|
|
|
|
Try to put dropdownlist out of UpdatePanel and check if index of ddl return to 0 again.
Does the ddl have autopostback property to true?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you then save my time by voting my post.
|
|
|
|
|
Hi , i am developing an application in which
1. An Admin register a company(he can register any number of companies), and assigns a Administrator to it.
2. This Administrator then creates a Role Hierarchy for eg manager, deputy manager , consultant according to his company hierarchy and assigns user to any of this Role and set of pages .
3.No low role user can access high role user pages but vice versa is possible for eg. Manager can access deputy manager pages but dm cannot access manager pages.
(THIS WHOLE PROCEDURE IS REPEATED FOR EVERY COMPANY)
4. Now i want to implement Role and Authorization Api in this, how can I implement that
Please suggest me any ides if u have any
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
modified on Tuesday, September 2, 2008 6:50 AM
|
|
|
|
|
a good approach is to dynamically load the menu based on user role
|
|
|
|
|
pls i want the following line of code that cotain dml to fail or success at the same time. any idea pls
objtrial.insertregistration(Me.txtdistid.Text,Me.txtsurname.Text,Me.txtfirstname.Text)
If sponsid.ToLower.Trim.Equals("tradebay") Then
'Exit Sub
Else
levelid = 1
achieved = 1
Do
If Not objtrial.getResidual(sponsid, levelid, ymonth) Then
objtrial.insertresidual(sponsid, levelid, achieved, ymonth)
Else
objtrial.updateresidual(sponsid, levelid, achieved, month)
End If
levelid = levelid + 1
sponsid = objtrial.getsponsorID(sponsid)
Loop While Not (sponsid.Trim.ToLower.Trim.Equals("tthe"))
End If
|
|
|
|
|
It is not good to double post same question!
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you then save my time by voting my post.
|
|
|
|