Archive
UpdatePanel and triggers from a repeater control
If you want to backstop on some controls click you must need to specify triggers in UpdatePanel
For example:
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"> <ItemTemplate> <%# Eval("Name") >%> <asp:Button ID="Button1" runat="server" Text="Button" /> </ItemTemplate> </asp:Repeater> </ContentTemplate> <Triggers> <asp:PostBackTrigger ControlID="Buton1" /> </Triggers> </asp:UpdatePanel>
You will face following error message with above code
A control with ID ‘Button1’ could not be found for the trigger in UpdatePanel ‘UpdatePanel1’.
Here is simple solution for above problem
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"> <ItemTemplate> <!--when cick the button1, it will fire the btnDummy--> <asp:Button ID="Button1" Text="Click" OnClientClick="$get('btnDummy').click();return false;" runat="server" /> </ItemTemplate> </asp:Repeater> <!--Make a hidden button to treat as the postback trigger--> <asp:Button ID="btnDummy" runat="server" Style="display: none" Text="HiddenButton" />
Send Email from a Static HTML
Send an email without back-end/server side code.
There are many solutions available for sending an email here I am explaining steps to sending an email from html page using Google Apps mail.
1. Make a Copy of the Sample Spreadsheet.
Sample: https://docs.google.com/spreadsheets/d/1Bn4m6iA_Xch1zzhNvo_6CoQWqOAgwwkOWJKC-phHx2Q/
2.Open the Script Editor
Open the Script editor… by clicking “Tools” > “Script editor…”
3. Set the TO_ADDRESS
in the Script
4. Save a New Version of your Script
Goto File-> Manager Version option to set Version
5. Publish the Updated Script as a Web App
Goto menu Publish-> Deploy as Web app option to publish
Select the latest project version to deploy:
6. Authorize the Script to Send Emails
Click Continue to authorize this app
Copy the web app URL to your clip board / note pad. Then Click “OK”.
7. Create your basic HTML Form
8. Open the HTML Form (page) in your Browser
Fill in some sample data in the HTML Form:
Submit the form. You should see a confirmation that it was sent like
{“result”:”success”,”data”:”{\”color\”:[\”\”],\”name\”:[\”Rahul\”],\”message\”:[\”This is test \”],\”email\”:[\”rahulgbhatia@live.com\”]}”}
Alternate solution : Use Ajax to submit the form
Hope this help !
Background Reading
- Google Apps Scripts Basics: https://developers.google.com/apps-script/articles
- Logger (like console.log): https://developers.google.com/apps-script/reference/base/logger
- Simple Mail Merge using Google Spreadsheets: https://developers.google.com/apps-script/articles/mail_merge
- Original Tutorial: AJAX post to google spreadsheet: http://stackoverflow.com/questions/10000020/ajax-post-to-google-spreadsheet which points to:
Unable to launch the ASP.NET Development server because port ‘1900’ is in use
The Problem
You are coding away, Visual Studio locks up for one of it’s many reasons, and reopen your project and run it again. You then get the “Unable to launch the visual studio development server because port 9452 is in use” error
The Cause
When Visual Studio crashed, the Web Server did not, so basically it thinks you are trying to run two instances at the same time, which is not allowed.
The Solution
Open up the process manager, go to the Processes tab, and select “WebDev.WebServer40.exe” and click “End Process”. Then try running your project again. Visual Studio will now start the project fresh and the problem should go away.
Or try this
Hope it helps !
Pound Symbol
To type pound symbol press ALT + 0163
Expression for Email Address validation in C#
<asp:TextBox ID=”txtEmail” runat=”server”></asp:TextBox>
—————————————————————————-
<asp:RegularExpressionValidator ValidationExpression=”^([a-zA-Z0-9_\-\+\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$” ID=”rxpEmail” runat=”server” ErrorMessage=”Email Address is not valid” ControlToValidate=”txtEmail”>
—————————————————————————-
For Online Testing
Server.Transfer v/s Response.Redirect
Response.Redirect(“newpage.aspx”) and Server.Transfer(“newpage.aspx”)
- Response.Redirect involves a roundtrip to the server whereas Server.Transfer conserves server resources by avoiding the roundtrip. It just changes the focus of the webserver to a different page and transfers the page processing to a different page.
- If you are using Server.Transfer then you can directly access the values, controls and properties of the previous page which you can’t do with Response.Redirect.
- Response.Redirect changes the URL in the browser’s address bar. So they can be bookmarked. Whereas Server.Transfer retains the original URL in the browser’s address bar. It just replaces the contents of the previous page with the new one.
- Response.Redirect can be used for both .aspx and html pages whereas Server.Transfer can be used only for .aspx pages and is specific to ASP and ASP.NET.
- Response.Redirect can be used to redirect a user to an external websites. Server.Transfer can be used only on sites running on the same server. You cannot use Server.Transfer to redirect the user to a page running on a different server.
Comments